I have a form that relies on a series of lookups to populate most of the form. I recently added a button to allow users to refresh all the lookups. Enter the trouble. Not all the data returns which I know it is present. Entire tables are blank which should not be. So I decided to jump into the javaScript (not jQuery) to try and systematically order the lookup rules. First lookup rule was for just fields, no tables/collections. I have that working well using subscribe/unsubscribe since using the onlookupDone was looping on itself and growing exponentially.
The next lookup rule is a table. Big complaint here about subscribe: why can't it point to the field that triggers the lookup? I had to deal with this with my first lookup, but pointing to a specific cell in a specific row in a table does not seem possible using subscribe. I'm good with just the first cell in the first row. I tried (as pointed out in the help doc) to add the index but no luck there.
example: {fieldId: 2, index: 2}
Here is what i have for non-table/collections as a reference:
window.changeGU = async function(){
console.log("lookup trigger");
var guVal = LFForm.getFieldValues({fieldId: 23}); //'2AD1BEA0-05D4-4AE6-BD38-D7102DC1B286';
//main incident fields
var gu1 = function(){
//subscribe to IncidentID field before lookup trigger
LFForm.subscribe("lookupDone",() => {
console.log("lookDone1-1");
//only here to inform when lookup complete
//subscribe to School field to see when lookup complete
LFForm.subscribe("lookupDone", () =>{
console.log("lookDone1-2");
},{fieldId: 30});
//add value back to field to retrigger repopulate
LFForm.setFieldValues({fieldId: 23}, guVal);
},{fieldId: 22});
LFForm.unsubscribe("lookupDone", {fieldId: 30});
//clear value out
LFForm.setFieldValues({fieldId: 23}, "");
}; //end gu1
LFForm.unsubscribe("lookupDone", {fieldId: 22});
await gu1();
};//end window.changeGU
I have tried adding a "[0]" after the fieldId as well. Anyone have a tip?