生活怎么样... 我是 Microsoft Dynamics 的新手...
谁能告诉我为什么这段代码对账号有效,但对收入没有任何作用...不会在字段中写入值???
using System;
// Microsoft Dynamics CRM namespace(s)
using Microsoft.Xrm.Sdk;
namespace Microsoft.Crm.Sdk.Samples
{
public class accountManager : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the execution context from the service provider.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
switch(entity.LogicalName)
{
case "account":
int accountNumber;
accountNumber = 100;
entity.Attributes.Add("accountnumber", accountNumber.ToString());
int accountRevenu;
accountRevenu = 1000;
entity.Attributes.Add("revenue", accountRevenu.ToString());
break;
}
}
}
}
}
致以诚挚的问候 斯蒂芬
最佳答案
收入是“货币”字段,因此您应该尝试使用以下代码:
entity["revenue"] = new Money(1000);
关于crm - 微软动态插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32972788/