var onLoad = function () {
"use strict";
debugger;
/// <summary>
/// Set contact field required
/// Set Product and Version field not required on create
/// </summary>
var fromParameterCtrl = null;
var statusCodeCtrl = null;
var statusCodeAttr = null;
var statusCodeAttrValue = null;
statusCodeCtrl = Xrm.Page.getControl(constants.statuscode);
fromParameterCtrl = Xrm.Page.getControl(constants.fromParameter);
if (statusCodeCtrl) {
statusCodeAttr = Xrm.Page.getAttribute(constants.statuscode)
if (statusCodeAttr != null) {
statusCodeAttrValue = statusCodeAttr.getValue();
var fromparameter=Xrm.Page.getAttribute(constants.fromParameter).getValue();
var id = fromparameter[0].id.replace("{", "").replace("}", "");
if (id === "3fea92bc-9496-e611-80e8-c4346bac3908" || id === "3FEA92BC-9496-E611-80E8-C4346BAC3908") {
return;
}
//// Check if status of Email is Draft or not.
//// If Draft, set From Parameter as "Support Queue"
if (statusCodeAttrValue === 1) {
if (fromParameterCtrl) {
//// Fetch the Support Queue and set on From parameter
fetchSupportQueue();
}
else {
Xrm.Utility.alertDialog("From parameter control is not found");
}
}
}
}
};
var onSuccessCallbackSupportQueue = function (data) {
"use strict";
if (data && data.value.length > 0) {
var partlistData = new Array();
partlistData[0] = new Object();
partlistData[0].id = data.value[0].queueid;
partlistData[0].name = data.value[0].name;
partlistData[0].entityType = constants.entityTypeQueue;
Xrm.Page.getAttribute(constants.fromParameter).setValue(partlistData);
Xrm.Page.getAttribute(constants.fromParameter).setSubmitMode();
//Xrm.Page.data.entity.save(null);
}
else {
Xrm.Utility.alertDialog(errorMessage.Support_Queue_not_found);
}
};
The onLoad function is called on form Load. fetchSupportQueue function basically calls the Retrieve function for Support Queue User.