0

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 enter image description here

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

Thanks in advance Carolyn

Carolyn Cordeiro
  • 1,525
  • 3
  • 11
  • 26

1 Answers1

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', '');
        }
    },
eyescream
  • 18,088
  • 2
  • 34
  • 46
  • 1
    Consider going for some JavaScript programming training? Or maybe the trailhead modules and projects such as https://trailhead.salesforce.com/en/content/learn/projects/quickstart-lightning-components or https://trailhead.salesforce.com/en/content/learn/projects/workshop-lightning-programmatic There's only so much copy-pasting internet strangers' code can do for you ;) – eyescream Oct 07 '20 at 07:32
  • is it possible to make level1 level2 and level3 code also as search boxes instead of just text boxes ,like user can type text in level1 and level2 and level3 gets autopopulated or type some valid string in level2 so that level1 and level3 gets autopopulated – Carolyn Cordeiro Nov 04 '20 at 08:19
  • 1
    Sounds doable but it's a nice little project to do it carefully, so the change of field 2 doesn't create neverending loop of changes to field 1 & 3, them firing off new searches... Bit too much for the kind of help we tend to give here. If you make new question there's high chance you'll get answers like "what have you tried to do, what errors/problems you encountered". Like the guidelines you see in sidebar when writing new question. Have you considered hiring a developer, some consultancy/SF partner or even posting on https://appexchange.salesforce.com/jobs? Freelancer would happily take it – eyescream Nov 04 '20 at 11:01
  • any help on this why cached Level2 and level3 values are sent even when values are reset at the component level thank you https://stackoverflow.com/questions/64868673/setting-dependent-custom-lightning-picklist-level2-and-level3-then-resetting-the – Carolyn Cordeiro Nov 17 '20 at 05:32
  • It's not easy to say or reproduce. Your original component is hopelessly old (I mentioned it's going to be deprecated in May'21, right?), hard to create new code that would still be using it. I'm bit flooded in my 9-5 work, sorry. – eyescream Nov 17 '20 at 22:06
  • thank you again i have completely changed the code to make it modern ,if you can look into this ,now I am very close with dependent dropdown list and provided all code and article referenced ,here is question https://stackoverflow.com/questions/64903319/why-picklist-not-populating-data-for-custom-dependent-picklist-field-with-lightn – Carolyn Cordeiro Nov 19 '20 at 00:03