Thursday, August 1, 2024

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

Introduction:

In this blog we will see 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 :)

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...