Global API
Code Examples

Invokable Class for Flow

3min

This is an example class, which can be invoked by a standard Flow. This is quite useful as it shows how you can use Salesforce standard automation practices to drive NetSuite record creation. Using this format you can extend to Update or Read in a similar fashion.

This basic example shows how easy it is to create robust automation in Salesforce to facilitate record creation in NetSuite. Extending upon this, using the Global API requests in this help site you can perform many automated retrieve, create, or update functions directly rather than requiring extensive middleware or endpoint processing to perform.

Apex Class: BW_CreateNetSuiteCompany_Invokable Utilizing @InvocableMethod allows this class to be selected in Flow, as an Apex Action.

BW_CreateNetSuiteCompany_Invokable


In a Salesforce Flow you will add an Apex Action, passing the desired values in and retrieving the NetSuite Response back:

Sample Company Creation Flow
Sample Company Creation Flow




Note how recordId is used to ensure the Flow is operating on the Account it was clicked from.

Get Salesforce Account - Detail View
Get Salesforce Account - Detail View




Account Confirmation Screen - Detail View
Account Confirmation Screen - Detail View






Adding an Action to the Flow
Adding an Action to the Flow


Adding an Action to the Flow that calls the Apex Class is what is required.

Selecting the Invokable Class
Selecting the Invokable Class




Here you will set all the input and output fields needed. *Note: The fields in the class Requests and Results section(s) are indicated with @InvocableVariable. The class provides which fields are selectable in the above Flow's detail page, so if it's not able to be selected you will need to update the class.

Apex Action - Detail View
Apex Action - Detail View


Finally, the responses that NetSuite sends back will indicate success, or failure in creating the NetSuite Company from this Salesforce Account.

NetSuite Result Screen - Detail View
NetSuite Result Screen - Detail View