Populate Lookup Based on Selection of Another Lookup
Create 2 lookup fields in your Form
i have created lookup1 and lookup2
Next,
Create web resource with the below code
function LookupValue(executionContext){
var formContext = executionContext.getFormContext();
var lookupvalue1= formContext.getAttribute(“test_lookup1”);
if (lookupvalue1 != null) {
var lookup = lookupvalue1.getValue();
if ((lookup != null)) {
if (lookup[0].id != null) {
var lookup1 = new Array();
lookup1[0] = new Object();
lookup1[0].id = lookup[0].id;
lookup1[0].name = lookup[0].name;
lookup1[0].entityType = lookup[0].entityType;
formContext.getAttribute(“test_lookup2”).setValue(lookup1);
}
}
}
}
Go to Form editor —> Select lookup1 field properties —> Click Events –> Add the Web Resource with the above code
Next,
Add it in the Form Libraries and Event Handlers
Next open your App and test it.
Before selecting record in lookup

After selecting a record in lookup 1 and it populated same record in lookup 2