Announcements
Hi, hope this is the correct section for this post. I am attempting use javascript to autofill items in my model-driven form.
So I have a column that is a lookup called job role and if users select a job, it will automatically go to another lookup column and select the role type for the user.
Job Role is a lookup column and Role is a second lookup to another column. I attempted the below, but it is not filling out any items and when I delete an a selected job type I keep getting error: Cannot read properties of null (reading '0').
function autoPopulateRole(executionContext){ var formContext = executionContext.getFormContext(); formContext.ui.setFormNotification(/Testing v1/,/INFO/) var selectedFunctionalRoleTypeRef = formContext.getAttribute(/jobrolelookup/).getValue()[0]; var Entity = selectedFunctionalRoleTypeRef.entityType; var Id = selectedFunctionalRoleTypeRef.id var Select = /?$select=roleLookup/; var selectedJob = Xrm.WebApi.retrieveRecord( Entity, Id, Select).then( function success(result) { console.log(/Success: / + result.roleLookup); }, function (error) { console.log(error.message); }); var lookUpRole= selectedJob.roleLookup; formContext.getAttribute(/joblookup/).setValue(lookUpRole);
André Arnaud de Cal...
293,998
Super User 2025 Season 1
Martin Dráb
232,850
Most Valuable Professional
nmaenpaa
101,158
Moderator