Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Set Option set value into a text field

$
0
0

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.


 


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>