I am very new to Dynamics CRM. My goal is to get the value of an OptionSet field on ABC table and set the same OptionSet field in a different table with the same value. The script is set for onChange on table ABC. The initial error was a MaxPage error. Now when I check the debugger, I see that the API call gets completely skipped. Thanks in advance for your help.
No worries. You are already on right path, so it will be needed some changes as per your requirements that is it.
Let me know if more information needed.
Thank you,
Amit Katariya
Hi Amit,
Thanks for the assistance. I used parts of your script to complete the task. I needed to do the retrieval first to check if the field on the ABC table matched the field on the additional table first. Then I made the update if there wasn't a match.
Best,
Hello Maurice,
You already have the GUID of a record where you want to update the option set. so why you are retrieving it?
Just use below code which will help you to update the option set and remove the retrieve code from your code.
function updateFunction(executionContext) { var formContext = executionContext.getFormContext() var recordId = formContext.data.entity.getId(); var record = {}; record.fieldlogicalname = formContext.getAttribute("fieldABCTable").getValue(); // Replace fieldlogicalname with option set logical name if (formContext.getAttribute("fieldABCTable").getValue() !== null) { recordId = recordId.replace(/[{}]/g, ""); Xrm.WebApi.online.updateRecord("mention entity Name", recordId "", record).then( function success(result) { var updatedId = result.id; console.log(updatedId); }, function(error) { console.log(error.message); } ); } }
Thank you,
Amit Katariya
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Eugen Podkorytov
106
Muhammad Shahzad Sh...
106
Most Valuable Professional