Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

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 :)

Basic event handling - Onload, Onchange in MSCRM / Dataverse

  Introduction: Day 3 : Basic event handling - Onload, Onchange in MSCRM / Dataverse Script : function onChange(executionContext) { debu...