我在服务活动表单中附加了一些Javascript,它触发了OnLoad。它检索与服务案例(与服务活动相关)关联的TechId,并尝试默认为此用户设置服务活动的资源。
正如您在上面的屏幕截图中看到的,它会在“资源”字段中插入正确的“名称”,但由于图标“已损坏”,它似乎无法正确解析。如果我删除它并手动添加相同的用户,一切都很好。如果我尝试保存此活动,就像它在图像中一样,我会收到一个错误,指出调度引擎有问题。
我用来设置此值的代码是;
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");
};
答案 0 :(得分:4)
“Tony Harley”真的是account
还是systemuser
?
partylist[0].entityType = "account"; //entity schema name of account or contact