1
我有一些JavaScript附加到服務活動窗體,它觸發OnLoad。它檢索與服務案例相關聯的TechId(與服務活動相關),並嘗試默認將該服務活動的資源設置爲該用戶。設置PartyList值沒有被正確解析
正如你可以在上面的截圖中看到,它插入正確的「姓名」到資源領域,但它似乎並沒有妥善解決它的圖標是「腐敗」。如果我刪除它並手動添加同一用戶,則一切正常。如果我嘗試並保存圖像中的此活動,則會生成指向計劃引擎有問題的錯誤。
我用來設置這個值的代碼是;
function SetTechId()
{
if (Xrm.Page.getAttribute("resources").getValue() == null)
{
if (Xrm.Page.getAttribute("regardingobjectid").getValue() != null)
{
var caseId = Xrm.Page.getAttribute("regardingobjectid").getValue()[0].id;
var endPoint = getODataEndPoint();
var odataSelect = endPoint + "/IncidentSet?$select=new_new_fieldtechs_incident/OwnerId,new_new_fieldtechs_incident/OwningUser&$expand=new_new_fieldtechs_incident&$filter=IncidentId eq guid'" + caseId + "'";
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: odataSelect,
beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
success: function (data, textStatus, XmlHttpRequest)
{
if (data.d != null)
{
var fieldTech = data.d.results[0];
var ownerId = fieldTech.new_new_fieldtechs_incident.OwnerId;
//because the resources field in the service activity is a partylist, we need to treat this differently
var partylist = new Array();
partylist[0] = new Object();
partylist[0].id = ownerId.Id; //Guid (i.e., Guid of User or Contact etc)
partylist[0].name = ownerId.Name; //Name (i.e., Name of User or Contact etc)
partylist[0].entityType = "account"; //entity schema name of account or contact
Xrm.Page.getAttribute("resources").setValue(partylist);
}
},
error: function (XmlHttpRequest, textStatus, errorThrown) { }
});
}
}
}
function getODataEndPoint() {
return Xrm.Page.context.prependOrgName("/xrmservices/2011/OrganizationData.svc");
};
好的現場,我有一個高級時刻和思維帳戶意味着用戶。我可以使用systemuser代替帳戶嗎? – sparkymark75
是的,我認爲這就是我期望看到的。 –