Please wait, loading...

 
< class="bt_bb_headline_tag">basic plugincurrency type fieldms crm 2011ms crm 2013MSCRM 2011MSCRM 2013PLUGINset currency type field value
in MS CRM 2011 2013" subheadline="<span class="btArticleDate">March 13, 2014</span>" font="" font_weight="" font_size="" color_scheme="" color="" align="" url="" target="_self" html_tag="h1" size="large" dash="bottom" el_id="" el_class="" el_style="" supertitle_position="outside" ignore_fe_editor="true"]
THIS PLUGIN SIMPLY UPDATE AN FIELD (currency) VALUE TO AN GIVEN VALUE ON CREATION OF NEW RECORD : AS CURRENCY TYPE HAS TO BE TYPE CAST TO “Money”.


Currency Type Field  value can not be set as INT  or  STRING




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.ServiceModel;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Portal;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;

namespace plugin1
{
    public class Class1 :IPlugin
    {
        public void Execute( IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof (IPluginExecutionContext ));
            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory )serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

  // Retrieve all fields and records from the Entity “new_teston” 
            new_teston test = (new_teston)service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet (true ));
                       // convert value into Money type            Money mon = new Money(1000000);
            test.new_currency = ( Money)mon;
// for date type  
                DateTime dnew = new DateTime (1991, 5, 22);

            test.new_dateonly = ( DateTime)dnew;

 service.Update(test);
         

        }
    }
}






SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651&ssl=1
Microsoft Dynamics Community Profile

Learn more