0% found this document useful (0 votes)
10 views2 pages

Createtask

...

Uploaded by

yasir abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Createtask

...

Uploaded by

yasir abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;

namespace leadMang
{
public class CreateTask : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Get the required interfaces from the service provider
IPluginExecutionContext context =
(IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)
);

Entity entity;

// Check if the input parameters property bag contains a target


// of the create operation and that target is of type Entity.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target business entity from the input parameters.
entity = (Entity)context.InputParameters["Target"];

// Verify that the entity represents a contact.


if (entity.LogicalName != "lead") { return; }
}
else
{
return;
}

try
{
// IOrganizationServiceFactory
IOrganizationServiceFactory factory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationService
Factory));

// IOrganizationService
IOrganizationService service =
factory.CreateOrganizationService(context.UserId);
// List<string> parentSubjects = new List<string>();

}
catch (Exception ex)
{

throw ex;
}
}
}
}

You might also like