Auto reset the Custom Salesforce Lightning Level Fields

ⅰ亾dé卋堺 提交于 2020-12-15 08:34:02

问题


I was able to create a full search of case types using this thread How To Implement Full Search in Case Type using Salesforce? ,but now i have a need where I would like to auto reset Custom Salesforce Lightning Level Fields to null after cross button is selected Right now i have to refresh the entire salesforce page to clear the level fields of salesforce lightning component

Please let me know how do I clear the level1 and level2 and level3 data after clicking cross

Thanks in advance Carolyn


回答1:


Change this


useSelected: function(component, event, helper) {
        const selection = component.get('v.selection');
        const errors = component.get('v.errors');
        if (selection.length) {
            if(errors.length){  // Clear errors, if any
                component.set('v.errors', []);
            }
            let levels = selection[0].subtitle.split('; ');
            component.find('Level_1__c').set('v.value', levels[0]);
            component.find('Level_2__c').set('v.value', levels[1]);
            component.find('Level_3__c').set('v.value', levels[2]);
        }
    },

to


useSelected: function(component, event, helper) {
        const selection = component.get('v.selection');
        const errors = component.get('v.errors');
        if (selection.length) {
            if(errors.length){  // Clear errors, if any
                component.set('v.errors', []);
            }
            let levels = selection[0].subtitle.split('; ');
            component.find('Level_1__c').set('v.value', levels[0]);
            component.find('Level_2__c').set('v.value', levels[1]);
            component.find('Level_3__c').set('v.value', levels[2]);
        } else {
            // Somebody "selected" empty option = cleared the search box
            component.find('Level_1__c').set('v.value', '');
            component.find('Level_2__c').set('v.value', '');
            component.find('Level_3__c').set('v.value', '');
        }
    },


来源:https://stackoverflow.com/questions/64235294/auto-reset-the-custom-salesforce-lightning-level-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!