I am trying to get the values of market segment from lead from and use it to disable fields on the related entity, but my code does not work please help if you could i am new to javascript
market segment is option set
function GetMarketSegment(executionContext)
{
var formContext = executionContext.getFormContext()
if(new_marketsegmentcode = 359030000,359030003,359030004)
{
disableFormFields;
}
}
function disableFormFields(executionContext) {
var formContext = executionContext.getFormContext()
executionContext.getFormContext.getAttribute.forEach(function (control, index) {
var controlType = control.getControlType();
if (controlType != 'iframe' && controlType != 'webresource' && controlType != 'subgrid')
control.setDisabled(true);
});
}
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: Xrm.Page.context.getClientUrl() "/api/data/v9.1/leads(new_marketsegmentcode)?$select=new_marketsegmentcode",
beforeSend: function(XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("OData-MaxVersion", "4.0");
XMLHttpRequest.setRequestHeader("OData-Version", "4.0");
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
},
async: true,
success: function(data, textStatus, xhr) {
var result = data;
var new_marketsegmentcode = result["new_marketsegmentcode"];
var new_marketsegmentcode_formatted = result["zipari_marketsegmentcode@OData.Community.Display.V1.FormattedValue"];
},
error: function(xhr, textStatus, errorThrown) {
Xrm.Utility.alertDialog(textStatus " " errorThrown);
}
});