How to connect a salesforce org to another salesforce org using API Model?
In this section, we will guide you through how to create a model. Before proceeding to the next step, it's important to understand what a Model is.
Reference: What is Model?
Steps to create an API type Model:
Pre-requisites
Before working with the API Model for REST API operations in noKodr, a connection must be established between two Salesforce orgs. Let's go through the steps required to connect the two Salesforce orgs.
We will refer to two orgs in this process:
Org A, which has noKodr installed, and
Org B, whose data will be accessed and used for REST API operations via noKodr's API Model.
Steps to Connect Two Orgs:
Create a connected app on Org B.
Reference: What is connected App? How to create it?
Note: Make sure to enter a dummy Callback URL when creating the app. The actual URL will be filled in after creating the authentication provider in Org A.
After creating the Connected App, copy the Consumer Key and Consumer Secret from the app config.
Next, create an Auth Provider in Org A.
Reference: How to create Auth Provider?
Copy the Callback URL generated here and paste it into the Connected App in Org B.
Create a Legacy Named Credential on Org A.
Set
Identity Type
toNamed Principal
.Set
Authentication Protocol
toOAuth 2.0
.Use the
Auth Provider
created in Step 3 as theAuthentication Provider
.Set Scope to
api full refresh_token
.Named Credential
The
Authentication Status
will initially show asPending
in the configuration. After saving the configuration, you will be redirected to Org B to authenticate the connection. Once authentication is complete, the connection between the two orgs will be successfully established.
API Type Model
Steps to perform REST API operations using noKodr:
Start by creating a layout
Reference: How to create a layout?
Open the created layout, and select Models from the building blocks on the left side
Start by knowing an API-type model.
Reference: What is API Type Model?
Click on the
+
button, to open a new model creation screen.
In the
Details
tab, fill in the details for the layout:
Type: Set the type to API.
Authentication Type: Select Connection.
Connection: Choose the Named Credential created in the earlier steps.
Label: Enter a label for identification.
Name: Provide a name for this configuration.
Execute on Load: Check this box only if you want to automatically fetch records when the component loads. This is typically used when binding the model to retrieve records from another org and display them in a table component.
To learn more about the details tab, click here
In the
Request
tab, enter the necessary details for the REST API request you want to perform with the other org.
Method: Choose the REST API call type which you want to perform, i.e.,
GET
,POST
,PUT
,PATCH
, etc.URL: Set the
OAuth URL
for the particularMethod
chosen earlier.
Note: As we have earlier set named credential, the URL will be specific which will preced the same: such as for GET
method, URL will be /services/data/v58.0/
.
IsArray?
Type
Schema Designer
To learn more about the request tab, click here
On the
Response
Tab, Fill in the details for the REST API response you want to achieve from another org.
Status Code
IsArray?
Type
Schema Designer
To learn more about the response tab, click here
Click Save to save the API Type Model you have created.
You are now ready to bind this API Type Model to other components, such as Table or Form, to view data from Org B.