look up to string Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/look-up-to-string/ Microsoft Dynamics CRM . Microsoft Power Platform Thu, 20 Mar 2014 09:37: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 look up to string Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/look-up-to-string/ 32 32 176351444 Copy Look up Value to Single Line Of Text (String) Using Plugin In MSCRM 2011 2013 http://microsoftdynamics.in/2014/03/20/copy-look-up-value-to-single-line-of-text-string-using-plugin-in-mscrm-2011-2013/ Thu, 20 Mar 2014 09:37:00 +0000 http://microsoftdynamics.in/2014/03/20/copy-look-up-value-to-single-line-of-text-string-using-plugin-in-mscrm-2011-2013/ 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));             //...

The post Copy Look up Value to Single Line Of Text (String) Using Plugin In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>

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;

            // retriving record data/value of single record of which lookup is ( as “r” contain its guid)
            new_teston stringcopy = (new_teston)service.Retrieve(new_teston.EntityLogicalName, r, new ColumnSet(true));

            // retrive fields from 2nd entity where wants to copy the string
            new_testto tes = new new_testto();
            tes.new_name = stringcopy.new_teston1;

            // coping string to an fiel on same entity
            test.new_stringcopied = stringcopy.new_teston1;

            service.Create(tes);
            service.Update(test);
        }

    }

}

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

The post Copy Look up Value to Single Line Of Text (String) Using Plugin In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
2829