问题
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