There is a caching mechanism implemented for Lookup to improve the performance of the eForm loading.
The caching is applicable for the current session (until the form is submitted) and for the exact same query. If the query change (where clause value change), Auto Lookup will retrieve new values.
The way it works is that browser form session maintains a list of lookups which have been executed within this form session and if it has to be executed again, the code first checks against this in memory collection to see if the value is present, it will return back the value directly else make a fresh API call back to server. This is particularly helpful in repeating sections of form where same values are being filled in dropdown of different row so for e.g. if I had 10 rows each of which has a country dropdown, it won;t make sense to execute that query for all 10 rows and slow down the form. So the first row executes the query and remaining 9 can point to same query result.
However if for some rare scenario this behavior has to be overridden, it can be done by adding the Java script code below in the Form JavaScript section.
eFormCustomSettings.currentForm.lookupCaching.excludeItems.push({lookupName:xxxx’,fieldId:’yyyy’})
Where
xxxx — > Is the Lookup Name
yyyy —- > Is the Internal name of the AutoLookup Control
Please note that the internal name of the field is optional and only required if the lookup was used with multiple controls in the form and you wanted to disable caching for one particular control only. If however you wish to disable it throughout the form, you can just pass lookup name
eFormCustomSettings.currentForm.lookupCaching.excludeItems.push({lookupName:xxxx’})
However you must have a genuine case of overriding this behavior within same form session where for same query within same form session, you expect different result back. Otherwise it is recommended not to alter it for form performance reasons.
I have a following scenario – We have button called ‘Validate Budget’ and it calls a lookup via JS API to check the budget availability however the user can call this multiple times during the same form session and in between the available budget keeps on changing as other users are also utilizing the same budget. In this scenario we want to disable the cache but as it is not an autolookup, and their is no field ID associated with it so how can we override the caching.
Due to caching, we are getting the same budget each time in same form even when the budget is changed in the back-end.
Please Suggest.
Thank You In Advance!
You need to pass the field’s internal name only if the same lookup is used multiple times in a form and if you want to disable caching for only one particular control that it is bound to.
If you want to disable caching for all instances in the form then just passing the lookupName should be sufficient. So if there is only one instance of that lookup being used in the form then they use as shown below.
eFormCustomSettings.currentForm.lookupCaching.excludeItems.push({lookupName:xxxx’})