Announcements
Can't seem to get this open form function to fill out more than one lookup field? It fill out regarding, which was easy to do because i got that example from the API Documentation, but then when trying to use that same example to fill out a second lookup field it won't work.
Field is "Expense Category" with schema "d365pros_projectexpensecategory", code wise my understanding is you schemaid, schemaname, and schematype at the end of each field but that doesn't seem to do anything.
Code below.
function OpenNewForm(id, name, ProjectExpID, ProjectExpName) { debugger //https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-navigation/openform var entityFormOptions = {}; entityFormOptions["entityName"] = "d365pros_approvals"; // Set default values for the Contact form var formParameters = {}; //formParameters["new_field1"] = "Sample"; //formParameters["new_field2"] = "Sample"; // Set lookup column Regarding - THIS WORKS! formParameters["regardingobjectid"] = id; // ID of the user. formParameters["regardingobjectidname"] = name; // Name of the user. formParameters["regardingobjectidtype"] = "salesorder"; // Table name. //This Lookup Field Won't Wor Though? formParameters["d365pros_projectexpensecategoryid"] = ProjectExpID; formParameters["d365pros_projectexpensecategoryname"] = ProjectExpName; //formParameters["d365pros_projectexpensecategorytype"] = "salesorderdetail"; // Open the form. Xrm.Navigation.openForm(entityFormOptions, formParameters).then( function (success) { console.log(success); }, function (error) { console.log(error); }); }
Any help would be appreciated.
I think that was the trick. I swear i tried that before, but I tried that again actually just after I posted this XD and of course it works now. I removed the Type altogether; I think that helped as well.
Hello,
Try to use
formParameters["d365pros_projectexpensecategory"] = ProjectExpID;
formParameters["d365pros_projectexpensecategoryname"] = ProjectExpName;
instead.
André Arnaud de Cal...
294,217
Super User 2025 Season 1
Martin Dráb
232,978
Most Valuable Professional
nmaenpaa
101,158
Moderator