new activity using plugin Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/new-activity-using-plugin/ Microsoft Dynamics CRM . Microsoft Power Platform Mon, 24 Mar 2014 13:17: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 new activity using plugin Archives - Microsoft Dynamics 365 Blog http://microsoftdynamics.in/category/new-activity-using-plugin/ 32 32 176351444 Create Activity Of An Phone Call On Create of Contact Using Plugin In MSCRM 2011 2013 http://microsoftdynamics.in/2014/03/24/create-activity-of-an-phone-call-on-create-of-contact-using-plugin-in-mscrm-2011-2013/ http://microsoftdynamics.in/2014/03/24/create-activity-of-an-phone-call-on-create-of-contact-using-plugin-in-mscrm-2011-2013/#comments Mon, 24 Mar 2014 13:17:00 +0000 http://microsoftdynamics.in/2014/03/24/create-activity-of-an-phone-call-on-create-of-contact-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 Microsoft.Xrm.Sdk;using Microsoft.Xrm.Sdk.Query; namespace ClassLibrary1{    public class Class1 : IPlugin    {        public void Execute(IServiceProvider serviceProvider)        {            IPluginExecutionContext context = (IPluginExecutionContext)             serviceProvider.GetService(typeof(IPluginExecutionContext));            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));   ...

The post Create Activity Of An Phone Call On Create of Contact 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 Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;

namespace ClassLibrary1
{
    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);

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

            PhoneCall phone = new PhoneCall();

            ActivityParty _from = new ActivityParty();
            _from.PartyId = new EntityReference(SystemUser.EntityLogicalName, context.UserId);

            ActivityParty _to = new ActivityParty();
            _to.PartyId = new EntityReference(Contact.EntityLogicalName, test.Id);

            phone.From = new ActivityParty[] { _from };
            phone.PhoneNumber = “9028170672”;
            phone.DirectionCode = true;   // true is for outgoing and false is for incoming
            phone.Subject = “phone call trial”;
            phone.To = new ActivityParty[] { _to };
            service.Create(phone);
        }

    }
}


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

The post Create Activity Of An Phone Call On Create of Contact Using Plugin In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
http://microsoftdynamics.in/2014/03/24/create-activity-of-an-phone-call-on-create-of-contact-using-plugin-in-mscrm-2011-2013/feed/ 1 2825
Create Email Activity OR Send Email using Plugin In MSCRM 2011 2013 http://microsoftdynamics.in/2014/03/24/create-email-activity-or-send-email-using-plugin-in-mscrm-2011-2013/ Mon, 24 Mar 2014 10:46:00 +0000 http://microsoftdynamics.in/2014/03/24/create-email-activity-or-send-email-using-plugin-in-mscrm-2011-2013/  Note: On create on new Contact An Email activity generates and email is assigned.  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;using Microsoft.Crm.Sdk.Messages;namespace ClassLibrary1{    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);            //  _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());           Contact...

The post Create Email Activity OR Send Email using Plugin In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>

 Note: On create on new Contact An Email activity generates and email is assigned.

 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;
using Microsoft.Crm.Sdk.Messages;
namespace ClassLibrary1
{
    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);

           //  _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
           Contact con = (Contact)service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet(true));
           Guid _contactId = con.Id;

          // Create the ‘From:’ activity party for the email
             ActivityParty fromParty = new ActivityParty
             {
                 PartyId = new EntityReference(SystemUser.EntityLogicalName, context.UserId)
             };

            // Create the ‘To:’ activity party for the email
             ActivityParty toParty = new ActivityParty
            {
                PartyId = new EntityReference(Contact.EntityLogicalName, _contactId)
            };

            // Create an e-mail message.
            Email email = new Email
            {
                To = new ActivityParty[] { toParty },
                From = new ActivityParty[] { fromParty },
                Subject = “e-mail”,
                Description = “SendEmail Message.”,
                DirectionCode = true
            };
            Guid _emailId = service.Create(email);

            // Use the SendEmail message to send an e-mail message.
            SendEmailRequest sendEmailreq = new SendEmailRequest
            {
                EmailId = _emailId,
                TrackingToken = “”,
                IssueSend = true
            };

            SendEmailResponse sendEmailresp = (SendEmailResponse)service.Execute(sendEmailreq);
        }
    }
}


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

The post Create Email Activity OR Send Email using Plugin In MSCRM 2011 2013 appeared first on Microsoft Dynamics 365 Blog.

]]>
2826