Microsoft Dynamis插件

时间:2015-10-06 14:39:25

标签: crm

生活如何...... 我是微软动力学的新手......

任何人都可以告诉我为什么这段代码可以正常使用帐号并且不会为revenu做任何事情......不会在字段中写入值???

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;
            }       
        }
    }
}

}

最诚挚的问候 斯蒂芬

1 个答案:

答案 0 :(得分:2)

收入是“货币”字段,因此您应尝试使用以下代码:

entity["revenue"] = new Money(1000);