LightningFlowComponents icon indicating copy to clipboard operation
LightningFlowComponents copied to clipboard

*QuickLookup* - _(QuickLightningLookupHelper.js)_ - Conditionally hidden child lookup is not receiving parent value for WHERE clause

Open RealEvanPonter opened this issue 3 years ago • 2 comments

After setting up a parent and child lookup, if you add conditional visibility to the child lookup component so it only displays when there is a value in the parent component, that child component is not receiving the value selected in the parent component for use in the WHERE clause. I suspected this was a timing issue - the child component needs to render first before the event that sets the filter values executes. I was able to remedy by setting a 10ms delay on the fireSaveFilter function, but wanted to post here to see if there is a more elegant solution.

Steps to reproduce

Steps to reproduce the behavior:

  1. Set up a quickLookup component as the parent
  2. Set up a quickLookup component as the child (in a way that behaves like a dependent lookup field relying on the value of the parent)
  3. Set conditional visibility on the child component so it renders when [parent component].selectedValue Is Null False
  4. Run the flow and select a value for the parent quickLookup
  5. Focus on the child quickLookup input to open the list of records

Expected behaviour

The value from the parent component is included in the WHERE clause

Actual behaviour

The value from the parent component is not included in the WHERE clause

Screenshots

Using quickLookup v1.1 (before 10ms delay is introduced) image

After 10ms delay is introduced image

Potential Solution

Add a 10ms delay to fireSaveFilter in QuickLightningLookupHelper.js

fireSaveFilter : function(component, recordId){
        console.log('EVENT: QuickEvtFilterValue');
        var ev = $A.get('e.c:QuickEvtFilterValue'); 
        console.log(ev);
        console.log(component.get('v.cmpId'));
        // var ev = component.get("e.filtervalue"); 
        ev.setParams({
            'MasterFilterValue' : recordId,
            'parent': component.get('v.cmpId')
        });
        setTimeout(() => {
            ev.fire();
        }, 10)
    },

If you feel this is the best solution, I can submit a PR with this change.

RealEvanPonter avatar Jan 10 '23 14:01 RealEvanPonter

I like this fix. Please submit a PR.

ericrsmith35 avatar Jan 10 '23 22:01 ericrsmith35

Evan! Long time! I hope you're doing well. Great, smart fix.

alexed1 avatar Jan 14 '23 21:01 alexed1