Dynamics CRM Xrm.Utility.openEntityForm passing lookup parameters

vic0228發表於2019-04-01

   關於 openEntityForm如何傳lookup值, 官方的文件裡是這麼寫的

function OpenNewContact() {
 var parameters = {};
 //Set the Parent Customer field value to “Contoso”.
 parameters["parentcustomerid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";
 parameters["parentcustomeridname"] = "Contoso";
 parameters["parentcustomeridtype"] = "account";
 //Set the Address Type to “Primary”.
 parameters["address1_addresstypecode"] = "3";
 //Set text in the Description field.
 parameters["description"] = "Default values for this record were set programmatically.";
 //Set Do not allow E-mails to "Do Not Allow".
 parameters["donotemail"] = "1";

 // Open the window.
 Xrm.Utility.openEntityForm("contact", null, parameters);
}

    但按照它這樣寫是報錯的,最後發現把type欄位去掉就可以了,即只賦值id和name值而不需要賦值type

                var loanerrequestitem = new Object();
                loanerrequestitem["dib_loaner_inventory"] = val.attributes["data-id"].value;
                loanerrequestitem["dib_loaner_inventoryname"] = val.attributes["data-sn"].value;
                loanerrequestitem["dib_loaner_model"] = val.attributes["data-model"].value;
                loanerrequestitem["dib_loaner_modelname"] = val.attributes["data-model-name"].value;
                loanerrequestitem["dib_loaner_request"] = loanerRequestId.replace('{', '').replace('}', '');
                loanerrequestitem["dib_loaner_requestname"] = parent.Xrm.Page.getAttribute("mdt_loaner_request_no").getValue();
            
                Xrm.Utility.openEntityForm("mdt_loanerrequestitem", null, loanerrequestitem, { openInNewWindow: true });

 

相關文章