Hi
I have been trying to set few fields when a lookup value is changed. The field values are being retrieved from the lookup Id. I was able to get text fields but I couldn't get value of option set. Thing is I need to set the option set value in a text field. Below the code I have been using.
function changespecifier() { var AccountLookup = Xrm.Page.getAttribute("new_specifier").getValue(); SDK.REST.retrieveRecord( AccountLookup[0].id, "Account", null, null, function (account) { Xrm.Page.getAttribute("new_specifierstreet").setValue(account.Address1_Line1); Xrm.Page.getAttribute("new_specifiercity").setValue(account.Address1_City); Xrm.Page.getAttribute("new_specifierstate").setValue(account.Address1_StateOrProvince); Xrm.Page.getAttribute("new_specifierzip").setValue(account.Address1_PostalCode); if (account.new_strategic != null) { var AccountValue = Xrm.Page.getAttribute("new_strategic").getOption(account.new_strategic.Value); var AccountText = AccountValue.text; Xrm.Page.getAttribute("new_specifiersa").setValue(AccountText); } }, function (message) { alert("ERROR: " + message); } ); Xrm.Page.data.entity.attributes.forEach( function (attribute, index) { Xrm.Page.getAttribute(attribute.getName()).setSubmitMode("always"); }); }
new_strategic is a optionset on account entity while new_specifiersa is a text field on the current entity.
Please suggest.
*This post is locked for comments