Hi, I am using Laserfiche 12 Cloud Modern Designer I would like to call a specific lookup rule (ID: 2) through JavaScript based on an input value, for this case example: Only when Field Id: 39 has 'run' as value. The Field Id :39 is a single Field.
Based on the LFForm object documentation I am using onLookupTrigger to cancel and not cancel the lookup rule. Sadly, it works only when the form is loaded. Since the lookup rule has no 'where' conditions it is triggered when the form is loaded and as the field id:39 has an empty value the lookup rule is canceled, this is ok for the business process, but after it is canceled I can't find a way to trigger it again when the field value of the field Id :39 is 'run'.
Is there a way to call a specific lookup rule through JavaScript in Laserfiche Cloud Modern Designer after the form has loaded
This is my code:
// Listen for changes to Field 39 and trigger the lookup rule accordingly
LFForm.onFieldChange(function() {
let run = LFForm.getFieldValues({ fieldId: 39 });
// Check if the field value is 'run'
if (run === 'run') {
// Allow the lookup rule to execute
LFForm.onLookupTrigger(function() {
return { cancelLookup: false }; // Do not cancel the lookup rule
}, { lookupRuleId: 2 });
} else {
// Cancel the lookup rule if the field value is not 'run'
LFForm.onLookupTrigger(function() {
return { cancelLookup: true }; // Cancel the lookup rule
}, { lookupRuleId: 2 });
}
}, { fieldId: 39 });
Thanks for your time on it.