first plugin Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/first-plugin/ Microsoft Dynamics CRM . Microsoft Power Platform Thu, 13 Mar 2014 12:29:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/cropped-Microsoftdynamics365-blogs.png?fit=32%2C32 first plugin Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/first-plugin/ 32 32 176351444 Plugin Tutorial 1 : Update ” Single Line Of Text ” field Value On Create Of Record [ Basic Plugin ] in MS CRM 2011 2013 http://microsoftdynamics.in/2014/03/13/plugin-tutorial-1-update-single-line-of-text-field-value-on-create-of-record-basic-plugin-in-ms-crm-2011-2013/ Thu, 13 Mar 2014 12:29:00 +0000 http://microsoftdynamics.in/2014/03/13/plugin-tutorial-1-update-single-line-of-text-field-value-on-create-of-record-basic-plugin-in-ms-crm-2011-2013/ THIS PLUGIN SIMPLY UPDATE AN FIELD (SINGLE  LINE OF TEXT) VALUE TO AN GIVEN VALUE ON CREATION OF NEW RECORD : There are few things to do before writing your code follow the steps: 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)         {     ...

The post Plugin Tutorial 1 : Update ” Single Line Of Text ” field Value On Create Of Record [ Basic Plugin ] in MS CRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
THIS PLUGIN SIMPLY UPDATE AN FIELD (SINGLE  LINE OF TEXT) VALUE TO AN GIVEN VALUE ON CREATION OF NEW RECORD :

There are few things to do before writing your code follow the steps:



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)
        {
           // Below three  line are to get service and context and will be same for all plugins
            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 ));
            // Store String “chetan” in Field new_singleline
            test.new_singleline = “chetan”;
            //service.update : to update the record , service.create : to create the record ,  service.delete : to delete
            service.Update(test);
         

        }
    }

}



NOTE  : Service.update : update the record (it don’t fire the plugin ) , Plugin Is Fired On Registering New Step In Plugin Registration Tool .





1. It Retrieve all field and there value from the entity ” new_teston 

new_teston test = (new_teston )service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet (true ));

2. Service.update : to update the record ,
    Service.create : to create the record ,
    Service.delete : to delete.

CLICK THE LINK TO SEE HOW TO BUILD .DLL FILE AND CONNECTION IN PLUGIN REGISTRATION TOOL

REGISTER NEW ASSEMBLY

BROWSE DLL FILE 


AFTER REGISTRATION 

NOW REGISTER NEW STEP (WHEN THE PLUGIN WILL FIRE)

WE WANT THE PLUGIN TO FIRE  ON CREATE OF NEW FORM

DONE


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

The post Plugin Tutorial 1 : Update ” Single Line Of Text ” field Value On Create Of Record [ Basic Plugin ] in MS CRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
2833