我们正在使用CRM 2013.我正在尝试创建一个在创建CRM帐户时触发的插件。然后插件将触发并发送属性' AccountNumber'进入内部Web服务。然而,web服务现在似乎没有被调用。
起初我以为我必须做一个PostImage,但后来决定不再使用它了。起初我还在使用" EntityMoniker"作为一个插件参数,然后将其更正为键入" Target"。
这是我的代码:
有人可以指导我朝正确的方向发展吗?
var targetEntity = context.GetParameterCollection<Entity>(context.InputParameters,
"Target");
if (targetEntity == null)
{throw new InvalidPluginExecutionException(OperationStatus.Failed,
"Target Entity cannot be null");}
// Make sure the new Account Id is available
if (!context.OutputParameters.Contains("id"))
{return;}
var accountID = new Guid(context.OutputParameters["id"].ToString());
//putting postImage here but not being used
var postImage = context.PostEntityImages["PostImage"];
if (postImage == null)
{throw new InvalidPluginExecutionException(OperationStatus.Failed,
"Post Image is required");}
var AccountNumber = context.OutputParameters["new_AccountNumber"].ToString();
var service = new ServiceClient("");
var newProp = new PropertySetup
{
_prop = new Property
{
_propertyNm = AccountNumber
}
};
service.CreateNewProperty(newProp);
service.Close();
答案 0 :(得分:0)
要更改new_AccountNumber属性:
var AccountNumber = context.OutputParameters["new_AccountNumber"].ToString();
到
var AccountNumber = targetEntity.Attributes["new_AccountNumber"].ToString();