Overriding Auto-Population of Call To and Call From on Phone Call Activity Using JavaScript (Dynamics 365 Customer Service)

Overriding Auto-Population of Call To and Call From on Phone Call Activity Using JavaScript (Dynamics 365 Customer Service)

When creating a Phone Call activity in Dynamics 365, the platform automatically populates party fields:

  • Main Form (Phone Call) - Call From is set to the current user
  • Quick Create - Call From and Call To are auto-populated based on the current user and related record.

If you have a requirement where you do not want Call To and Call From to be auto-populated on either the Main Form or Quick Create for Phone Call, you can override this behavior using a JavaScript web resource.

function clearPhoneCallParties(executionContext) {
    var formContext = executionContext.getFormContext();

    // Only on Create
    if (formContext.ui.getFormType() !== 1) {
        return;
    }

    var toAttr = formContext.getAttribute("to");
    var fromAttr = formContext.getAttribute("from");

    if (toAttr) {
        toAttr.setValue([]);
    }

    if (fromAttr) {
        fromAttr.setValue([]);
    }
}        

In your solution, create a new web resource, set the file type to JavaScript (JScript), and paste the code above. Make sure to publish the web resource once saved. Depending on your requirement, you can apply this to the Main Form, the Quick Create Form, or both. Navigate to the Phone Call entity, open the Phone Call form, add the web resource to the Form Libraries, and register clearPhoneCallParties as an OnLoad event handler with Pass execution context as first parameter checked. Save and publish once done.

To view or add a comment, sign in

More articles by Rachel Irabor

Explore content categories