Salesforce Connector

Actions

Interop Actions

The Salesforce Connector allows you to create Actions in Salesforce which can invoke Interop methods. This is achieved through the glueInvoke event that the Salesforce Connector makes available to all Salesforce Components. The glueInvoke event accepts two arguments as parameters - an Interop method name and a payload object containing arguments with which to invoke the specified Interop method.

In short, you have to create a Salesforce Component and Controller for it which will set the parameters for the glueInvoke event and fire it. After that, you need to assign this Action to a button for a Salesforce object (Contact, Account, Lead, etc.).

Action Example

Below you can see an example of creating a custom Action in Salesforce that will invoke an Interop method. The Action is then assigned to a button for the Salesforce Contact object.

Component

Open the Salesforce Developer Console:

Dev Console

Go to File > New > Lightning Component and add a name and description for the Component. Select "Lightning Quick Action" for "Component Configuration":

New Component

Click "Submit" and paste the following code in the newly opened .cmp file and save it to create the component:

<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordID" controller="GlueUtilityBarController">
    <aura:handler name="init" value="{!this}" action="{!c.openPortfolio}"/>
</aura:component>

Controller

To create the Controller, select "CONTROLLER" from the right menu of the Developer Console and paste the following code in the newly opened .js file and save it:

({
    openPortfolio: function (component, event, helper) {
        // Check the connection status.
        const connectionStatus = localStorage.getItem("connectionStatus");

        if (!connectionStatus || connectionStatus === "false") {
            // Display a toast if there is no established connection.
            const toastEvent = $A.get("e.force:showToast");

            toastEvent.setParams({
                title: "No connection to Glue42.",
                message: "Please, connect to Glue42 to continue.",
                type: "error"
            });
            toastEvent.fire();
        } else {
            // Get the `recordId` of the current object (`Client` in the example).
            const recordId = component.get("v.recordId");

            // Create a `payload` object,
            const payload = { "recordId": recordId };

            // Get the `glueInvoke` event.
            const appEvent = $A.get("e.c:glueInvoke");

            // Set the event parameters - `method` and `payload` - by passing
            // the name and arguments for the Interop method you want to invoke.
            // It is assumed that the method you want to invoke has already been registered
            // by another Glue42 enabled application.
            appEvent.setParams({ "method": "OpenClientPortfolio", "payload": JSON.stringify(payload) });

            // Fire the event.
            appEvent.fire(); 

            // Close the quick action.
            setTimeout(function () {
                $A.get("e.force:closeQuickAction").fire();
            }, 300);
        };
    }
})

Keep in mind that the Interop method you want to invoke first has to be registered by a Glue42 enabled application.

Assigning the Action

Next, you have to assign the created Action to a button of a Salesforce object (e.g., Contact). Go to Object Manager > Contact > Buttons, Links and Actions and click the "New Action" button. Enter the settings for the new action - choose "Lightning Component" for the "Action Type" and choose the created component from the "Lightning Component" dropdown menu. Specify a label and a name for the Action and save the action:

Action Settings

Go to Object Manager > Contact > Page Layouts > Contact Layout. Select the "Mobile and Lightning Actions" item in the "Contact Layout" section. Find the created Action among the available Actions, or use the search box:

Select Action

Drag and drop the Action in the "Salesforce Mobile and Lightning Experience Actions" section and click the "Save" button in the "Contact Layout" section.

The Action should now be available when you navigate to the "Sales" Lightning app and open a contact:

Action