So I have a field on accounts that is two option (yes/no) called new_taxable in the accounts entity. I have a case form that I am able to populate customer information on based on the code below, however I think I am missing something as far as the datatype
is concerned with option sets. Because when I pull the retirevedCustomer.new_taxable and try to alert it I get undefined. Can someone please help me understand how to fetch two option set values? Much appreciated.
function setphone() {
var existingcustomer = Xrm.Page.getAttribute('new_customer').getValue();
if (existingcustomer != null) {
var serverUrl;
if (Xrm.Page.context.getClientUrl !== undefined) {
serverUrl = Xrm.Page.context.getClientUrl();
} else {
serverUrl = Xrm.Page.context.getServerUrl();
}
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var customerRequest = new XMLHttpRequest();
customerRequest.open("GET", ODataPath + "/AccountSet(guid'" + existingcustomer[0].id + "')", false);
customerRequest.setRequestHeader("Accept", "application/json");
customerRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
customerRequest.send();
if (customerRequest.status === 200) {
var retrievedCustomer = JSON.parse(customerRequest.responseText).d;
var mainphone = retrievedCustomer.Telephone1;
var taxable = retrievedCustomer.new_taxable;
Xrm.Page.getAttribute('new_mainphone').setValue(mainphone);
Xrm.Page.getAttribute('new_mainphone').setSubmitMode('always');
alert(taxable);
return;
}
} else { return; }
}