Hi Guido Preite,
Thanks for you replay.
Please find the following code.
function hideConfirmedStatus() {
var picklistType = "statuscode";
var picklistTypeName = Xrm.Page.getControl(picklistType);
var picklistTypeAttribute = picklistTypeName.getAttribute();
var picklistTypeSelectedOption = picklistTypeAttribute.getSelectedOption();
var statusCode = Xrm.Page.getControl("statuscode").getAttribute().getSelectedOption();
var picklistMode = "md_mode";
var picklistModeName = Xrm.Page.getControl(picklistMode);
var picklistModeAttribute = picklistModeName.getAttribute();
var picklistModeSelectedOption = picklistModeAttribute.getSelectedOption();
var picklistModeSelectedText = "";
if (picklistModeSelectedOption != null) {
picklistModeSelectedText = picklistModeSelectedOption.text;
}
var Amount = Xrm.Page.getAttribute("md_amount").getValue();
if (statusCode != null) {
statusCodeText = statusCode.text;
}
if (statusCodeText != 'Confirmed') {
picklistTypeName.removeOption(899230002);
}
var opt2 = new Option();
opt2.text = "Confirmed";
opt2.value = 899230002;
//alert(Xrm.Page.data.entity.attributes.get("md_unitsaleid").getValue());
if (picklistModeSelectedText != "") {
if ((picklistModeSelectedText != "Payable Adjustment") && (picklistModeSelectedText != "Fund Transfer")) {
if ((Amount == 0) || (Amount == null)) {
}
else if (statusCodeText != "Confirmed") {
if ((Xrm.Page.data.entity.attributes.get("md_fromunitsaleid").getValue() != null) || (Xrm.Page.data.entity.attributes.get("md_unitsaleid").getValue() != null) || (Xrm.Page.data.entity.attributes.get("md_unitleasingid").getValue() != null) || (Xrm.Page.data.entity.attributes.get("md_contact").getValue() != null) || (Xrm.Page.data.entity.attributes.get("md_corporatecustomerid").getValue() != null)) {
picklistTypeName.addOption(opt2);
}
}
}
else {
if ((Xrm.Page.data.entity.attributes.get("md_fromunitsaleid").getValue() != null) || (Xrm.Page.data.entity.attributes.get("md_unitsaleid").getValue() != null)) {
if (statusCodeText != "Confirmed") {
picklistTypeName.addOption(opt2);
}
}
}
}
if (picklistModeSelectedText == "Payable Adjustment") {
var lookupObject = Xrm.Page.getAttribute("md_payableid");
if (lookupObject != null) {
var lookUpObjectValue = lookupObject.getValue();
if ((lookUpObjectValue == null)) {
picklistTypeName.removeOption(899230002);
}
}
}
if (picklistModeSelectedText == "Fund Transfer") {
var formType = Xrm.Page.ui.getFormType();
var serverUrl = Xrm.Page.context.getClientUrl();
//var customServerURL = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName();
//if(serverUrl != customServerURL)
//{
//serverUrl = customServerURL ;
//}
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
if (formType != 1) {
var receiptid = Xrm.Page.data.entity.getId();
var retrieveReq = new XMLHttpRequest();
var filter = "/md_fundacquisitionSet?" +
"$select=md_fundacquisitionId" + "&$filter=md_Receipt/Id eq guid'" + receiptid + "'";
retrieveReq.open("GET", ODataPath + filter, false);
retrieveReq.setRequestHeader("Accept", "application/json");
retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
retrieveReq.send(null);
var retrievedRecords = JSON.parse(retrieveReq.responseText).d;
if (retrievedRecords.results.length > 0) {
}
else {
picklistTypeName.removeOption(899230002);
}
}
else {
if ((Xrm.Page.data.entity.attributes.get("md_fromunitsaleid").getValue() == null) || (Xrm.Page.data.entity.attributes.get("md_unitsaleid").getValue() == null)) {
picklistTypeName.removeOption(899230002);
}
}
}
}