copy lookup to lookup Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/copy-lookup-to-lookup/ Microsoft Dynamics CRM . Microsoft Power Platform Thu, 20 Mar 2014 11:18: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 copy lookup to lookup Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/copy-lookup-to-lookup/ 32 32 176351444 Copy One LookUp Field Value To Anoher LookUp using Plugin (EntityReference) ( Copy Lookup to Lookup ) In MSCRM 2011 2013 http://microsoftdynamics.in/2014/03/20/copy-one-lookup-field-value-to-anoher-lookup-using-plugin-entityreference-copy-lookup-to-lookup-in-mscrm-2011-2013/ Thu, 20 Mar 2014 11:18:00 +0000 http://microsoftdynamics.in/2014/03/20/copy-one-lookup-field-value-to-anoher-lookup-using-plugin-entityreference-copy-lookup-to-lookup-in-mscrm-2011-2013/ Note : There is two way to copy lookup to Lookup value . 1. Both Lookup are on same entity  //   tes.new_testonlookups= test.new_testonlookup; 2 using EntityRefrence if the Process include more than 2 Entities. 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 ClassLibrary2{    public class Class1 : IPlugin    {        public...

The post Copy One LookUp Field Value To Anoher LookUp using Plugin (EntityReference) ( Copy Lookup to Lookup ) In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
Note : There is two way to copy lookup to Lookup value .

1. Both Lookup are on same entity  //   tes.new_testonlookups= test.new_testonlookup;

2 using EntityRefrence if the Process include more than 2 Entities.

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 ClassLibrary2
{
    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);

            // retrive record data/value on which plugin firing
            new_calculate test = (new_calculate)service.Retrieve(new_calculate.EntityLogicalName, context.PrimaryEntityId, new ColumnSet(true));

            // r contain Guid of the look up
            Guid r = test.new_testonlookup.Id;

     

            // retrive fields from 2nd entity where wants to copy the string
            new_testto tes = new new_testto();
            tes.new_name = test.new_name;
         
            // reff1 Cantain Reffrence of lookup with guid r
            EntityReference reff1 = new EntityReference(new_teston.EntityLogicalName, r);
            tes.new_testonlookups = reff1;

            // tes.new_testonlookups= test.new_testonlookup;  ( we can copy one look up to another lookup of same entity directlly )
             service.Create(tes);

        }

    }

}


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

The post Copy One LookUp Field Value To Anoher LookUp using Plugin (EntityReference) ( Copy Lookup to Lookup ) In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
2828