Xrm.Page.getAttribute返回null

时间:2017-04-27 14:28:33

标签: crm dynamics-crm-2016

我正在尝试根据作业和候选字段中的内容对查找进行过滤。当抓取作业和候选者的属性时,即使这些字段中存在值,它也会一直返回null。然后我也得到一个错误:

Query Builder Error. 
The specified record type does not exist in Microsoft Dynamics 365.

我甚至尝试过Xrm.Page.getAttribute("hc_joborder").getValue()并返回无法获取null值。

对这里发生的事情有任何想法吗?



function CustomPpcLookupView() {
    // Some GUID but only needs to be unique among the other available views for the lookup
    var viewId = "{00000000-0000-0000-0000-000000000001}";
    var viewDisplayName = "PPC records for this contact";

    //Only need ppc records for the selected candidate and job order
    var jobOrder = Xrm.Page.getAttribute("hc_joborder");
    var candidate = Xrm.Page.getAttribute("hc_candidate");
    Xrm.Utility.alertDialog(jobOrder);
    Xrm.Utility.alertDialog(candidate);
    if (!jobOrder) { return; }
    if (!jobOrder[0]) { return; }
    if (!jobOrder[0].id) { return; }
    if (!candidate) { return; }
    if (!candidate[0]) { return; }
    if (!candidate[0].id) { return; }

    //Get all approved ppcs that pertain to the selected joborder,candidate 
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
					  "<entity name='hc_candidateppc'>" +
					   "<attribute name='hc_candidateppcid' />" +
					   "<attribute name='hc_ppc_name' />" +
	                   "<attribute name='createdon' />" +
	                   "<order attribute='hc_ppc_name' descending='false' />" +
	                   "<filter type='and'>" +
	                      " <condition attribute='hc_approved' operator='eq' value='948050002' />" +

	                      " <condition attribute='hc_candidate' operator='eq' value='" + candidate[0].id + " uitype='contact'  />" +
	                      "<condition attribute='hc_joborder' operator='eq'  value='" + jobOrder[0].id + " uitype='hc_joborder'  />" +

                          " <condition attribute='hc_approvalstatusmanager' operator='eq' value='948050001' />" +
                         "<condition attribute='hc_approvalstatusleadership' operator='eq' value='948050001' />" +

		               "</filter>" +
		               "</entity>" +
		           "</fetch>";
    //Set up the whole view's UI
    var layoutXml = "<grid name='resultset' object='1' jump='hc_contract' select='1' icon='1' preview='2'>" +
					 "<row name='result' id='contractid'>" +
					  "<cell name='hc_candidateppcid' width='300' />" +
					  "<cell name='hc_ppc_name' width='200' />" +
					  "<cell name='createdon' width='100' />" +

					 "</row>" +
					"</grid>";

    try {
        //Set the view
        Xrm.Page.getControl("hc_candidateppc").addCustomView(viewId, "hc_candidateppc ", viewDisplayName, fetchXml, layoutXml, true);
    } catch (e) {
        Xrm.Utility.alertDialog("Error: " + e.message);
    }
}
&#13;
&#13;
&#13;

0 个答案:

没有答案