Tuesday, August 6, 2024

Trigger JavaScript on Business Process Flow Buttons in MSCRM or Dataverse

 ​Implementation Steps:

 
 
2. Click On Solutions
 
3. Create a New Solution
 
4. Create a New JavaScript (in my case its Opportunity.js)

 















5. Copy Paste the Below Code for your JavaScript
 
function onLoad(e) {
    var bpf = e.getFormContext();
    bpf.data.process.addOnPreStageChange(handlePreStage);
};

function handlePreStage(e) {
    var bpf = e.getEventArgs(), entityName = Xrm.Page.data.entity.getEntityName()

    if (bpf.getDirection() === "Previous") {

        bpf.preventDefault();

        var alertStrings = { confirmButtonLabel: "OK", text: "You have Clicked Previous button"};
        var alertOptions = { height: 150, width: 260 };

        Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);

        return;
    }
    if (bpf.getDirection() === "Next") {

        bpf.preventDefault();

        var alertStrings = { confirmButtonLabel: "OK", text: "You have Clicked Next button"};

        var alertOptions = { height: 150, width: 260 };

        Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);

        return;

    }
}

 
6. Now Open Opportunity Table --> Opportunity Form and add an ONLOAD EVENT
 













 
7. Once Done --> Save and Publish
 
 
8. Now Open Opportunity Table --> Open a Record
 
9. Click Business Process Flow --> Click Next
 


 
 








10. Again Click on Business Process Flow --> Click Back Button
 


 
 








That's it :)
 

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

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...