Skip to main content

Notifications

How to Set Required and Optional attendees using MSCRM or Dataverse Plugins

Implementation Steps:

1. Create a Project in VS

2. Create a .cs file and name it as appointment.cs

public class Appointment
{  
    public void Execute(IServiceProvider serviceprovider)
    {

        IPluginExecutionContext executionContext = (IPluginExecutionContext)iServiceProvider.GetService(typeof(IPluginExecutionContext));

        IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)iServiceProvider.GetService(typeof(IOrganizationServiceFactory));

        IOrganizationService service = serviceFactory.CreateOrganizationService(executionContext.UserId); 
     }
}

4. if the entity is appointment then do the following code

Entity entity = (Entity)executionContext.InputParameters["Target"];

5. Create a Party list

ActivityParty party = new ActivityParty
{
PartyId = new EntityReference("systemuser", new Guid("GUID"))
};

6. Update the Required and Optional attendees 

Entity appointment = new Appointment
{
Subject = "Sample Appointment",
RequiredAttendees = new ActivityParty[] { party },
OptionalAttendees = new ActivityParty[] { party }
};


7. Now Update the Appointment

service.Update(appointment);

That's it :)

Comments