locked
Crm 2015 RRS feed

  • Question

  • Hi...

    How is life...

    I'm quite new to CRM programming... I want to develop some Plugins to mange some fields and som custom entity and fields...

    I'm using the plugin exemple project from de CRM SDK...  espacially the one for creating an account number... an I'm just adding an extra fiel... annual revenu... to see if I can write to it...

    It work fine for the account number... but not for the annual revenu... also none of the other fields I'm trying...

    here is my sample/simple code...                              

    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"];

                    int accountNumber;
                    accountNumber = 100;
                    entity.Attributes.Add("accountnumber", accountNumber.ToString());

                    int accountRevenu;
                    accountRevenu = 1000;
                    entity.Attributes.Add("revenue", accountRevenu.ToString());

                }
            }
        }
    }

    Thank's in advance...

    Steph

    Tuesday, October 6, 2015 1:12 PM

Answers

  • Hello,

    Revenue is field of money type. Try to use following code instead:

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


    Dynamics CRM MVP
    My blog

    • Marked as answer by stedes_dev Tuesday, October 6, 2015 3:22 PM
    Tuesday, October 6, 2015 2:46 PM
    Moderator

All replies

  • Hello,

    Revenue is field of money type. Try to use following code instead:

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


    Dynamics CRM MVP
    My blog

    • Marked as answer by stedes_dev Tuesday, October 6, 2015 3:22 PM
    Tuesday, October 6, 2015 2:46 PM
    Moderator
  • Thank's alot... work fine

    Best Regards

    Steph

    Tuesday, October 6, 2015 3:21 PM