我被卡在XrmServiceToolkit.Soap.setState()
功能上。
先决条件我正在研究MS CRM。我的任务之一是激活和停用记录(这次是本地“联系人”记录)。我决定以以下方式(根据其他任务)构建我的解决方案:
function Practice3()
{
let entityToUpdate = CreateRecordWithToolkit("VP_Created by","Xrm Service Toolkit","4F52999B-0E63-EA11-8125-00155D06F203");
alert("Switching to new record!");
Xrm.Utility.openEntityForm("contact", entityToUpdate);
UpdateFieldsWithXrmServiceToolkit(entityToUpdate);
DeactivateAndActivateContact(entityToUpdate);
}
// I don't post the CreateRecordWithToolkit(fname, lname, accountId) and UpdateFieldsWithXrmServiceToolkit(targetEntity) functions 'cos all is Ok there
// and entityToUpdate GUID is passed properly
问题谁能解释或提示如何使用XrmServiceToolkit.Soap.setState()
功能?我无法获取“ entityName”参数-这是什么?拥有实体的GUID如何获得它?我试图像这样使用它:
function DeactivateAndActivateContact(targetEntity)
{
let entityName = GetObjectAttribute(targetEntity, "contact", "name");
XrmServiceToolkit.Soap.setState(entityName,targetEntity, "0", "0",false);
Xrm.Page.data.refresh(true).then(null, null);
}
但出现未定义的错误。
是否有任何方法可以通过GUID获得entityName
?因为我正在获取当前表格的名称。进入此行时引发错误:
XrmServiceToolkit.Soap.setState(entityName,targetEntity, "0", "0",false);
要在此处停用联系人,下面的代码,
注意Rest API call is Asynchronous,您将必须使用execution context and formcontext in Dynamics
此外,您还可以使用Rest API更改其他SOAP调用。请参阅CRM Rest Builder,使用它可以轻松建立呼叫。
var entity = {};
entity.statuscode = 2;
entity.statecode = 1;
Xrm.WebApi.online.updateRecord("contact", "4A342F12-D248-E211-8669-005056922461", entity).then(
function success(result) {
var updatedEntityId = result.id;
formContext.data.refresh(yes).then(successCallback, errorCallback);
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);