Skip to main content

Connecting Salesforce to Netsuite

User Guide: Configuring Source as Salesforce and Target as Netsuite.

 

This guide offers a detailed walkthrough for configuring Salesforce as the source and NetSuite as the target. By following these steps, you'll seamlessly establish a connection, retrieve desired data from the source, and efficiently transmit it to your chosen destination.

 

Data Source :

Step 1:

·       In the Data Source page, Select the source type as API

SS1.png

 

Step 2:

·       Now select the “Salesforce” as your product

salesforce1.png

Step 3:

·       Choose the appropriate business object based on your needs.

Salesforce 2.png


Note: In the event the desired product or business object isn't available, you have the option to select 'Create New' in the product name field. Provide the necessary details for the new product and the business object you intend to configure as the source.

Note: Opting for 'Create New' requires the user to furnish all necessary details essential for configuring the API as the source.

Step 4:

·       After selecting the business object (such as Account Information in this example), the system loads all prerequisites.

salesforce 3.png


·       Next, enter the instance identifier and Authorization details into the provided placeholders.

Salesforce 5.png




Note : We have the flexibility to make requests not just through standalone APIs but also by leveraging SOQL queries within the REST API.

Sample SOQL Format

https://{{instance identifier}}-dev-ed.my.salesforce.com/services/data/{{Version}}/query/?q={{query}}

Instances of queries could look like:

To apply filtering based on custom field values, we can utilize the following query format :

https://{{instance identifier}}-dev-ed.my.salesforce.com/services/data/{{Version}}/query/?q=SELECT+id__c,backorder__c,Brand__c,Category__c,Created_Date__c,Supplier__c,Location__c,Item_Name__c,Item_Number__c+FROM+Item__c+WHERE+Location__c = 'New-York'

To apply filtering based on minimum and maximum time values, we can utilize the following query format :

https://{{instance identifier}}-dev-ed.my.salesforce.com/services/data/{{Version}}/query/?q=SELECT+Id,Backorder__c,Brand__c,Category__c,Created_Date__c,Supplier__c,Location__c,Item_Name__c,Item_Number__c+FROM+Item__c+WHERE+Location__c='New-York'+AND+Created_Date__c >= '2023-01-01T00:00:00Z'+AND+Created_Date__c <= '2023-12-31T23:59:59Z'


Refresh Token Endpoint Body

Salesfoce 6.png


Configuration Keys in Refresh Token Endpoint Body :

  1. grant_type: Specifies the grant type being used for authentication. Common types include "password" for resource owner password credentials and "client_credentials" for client credentials.

  2. client_id: Represents the unique identifier assigned to the client (application) by the authorization server during the registration process.

  3. client_secret: Serves as a confidential key known only to the application and the authorization server. It's used to authenticate the identity of the client application.

  4. username: Refers to the username or identifier of the user accessing the API. This is typically used in combination with the password grant type.

  5. password: Represents the user's password associated with the provided username for authentication purposes when using the password grant type.

These keys are utilized in constructing the API endpoint URL to exchange credentials securely and obtain an access token required for accessing protected resources through the API.


 Note: Various API endpoint URLs feature distinct placeholders, therefore, users need to input all relevant details based on their specific requirements. Please refer to the Salesforce API documentation for further information.


Data Operations :

Step 6:

Salesforce 8.png


Single Line to Multiline

This 'Single Line to Multiline' operation facilitates the transformation of JSON data from a single-line format to a multiline format. It's particularly beneficial when handling responses received in a single-line JSON structure. By converting it to multiline JSON, it separates and organizes records, enabling easier application of subsequent operations on each individual record.

Reference Link:   Single line to Multiline

Filter

     If else is called as the filter operation in eZintegrations, basically it has 1 parameter : Conditional Statement

  1. Source has the JSON data of the previous operation
  2. Target is the JSON data after performing the filter operation
  3. Conditional Statement is the parameter where we include logical operators (and ,or, not),Identity operators(is ,is not),membership operators (iin,not in),comparisional operators(==,!=,>, <,<=,>=)


Within this process, we apply a filter operation to sort and extract records based on specific user-defined conditions.

Note : 'data' is fixed in the statement, we can change name of key and value as per requirement.

List of Operators that can be used : [==, !=, <, >, =<, =>, or, and]

Example 1 : Filtering data where Order Status is pending

data['Order Status']=='pending'

Example 2 : Filtering data where vale of "id" is 5 or 6.

data['id']==5 or data['id']==6

Example 3 : Filtering data where order status is not failed and placed before a specific date.

data['Order Status']!= 'failed' and data['Date']<'6/03/2022'

       

       Reference Link:  Filter

Append

This operation allows for the addition of a new key-value pair within your dataset by providing a comma-separated list of key-value pairs enclosed in double quotes. The 'Append' feature facilitates mapping these keys to target keys, thereby composing the payload intended for transmission to the Data Target.

Here's an example illustrating the construction of a JSON payload by mapping keys, ensuring these keys are transmitted to the designated target.

"keyname": {
                "id": "{%id%}",
                "email": "{%email%}",
                "first_name": "{%first_name%}"
            }



Reference Link:   Append

Sample constructed payload Intended for sending to Netsuite :

"payload": {
  "companyName": "{%Name%}",
  "custentity_ch_website_cust_id": "{%Id%}",
  "subsidiary": {
   "id": "2"
  }
 }

Note : When crafting the payload for Netsuite, it's essential to include specific mandatory keys. Omitting these keys will result in Netsuite rejecting the data


Data Target :

Step 7 : Choose the Target Type as 'API'.

TStep1.png

Step 8 : Enter 'Oracle NetSuite' in the target name field and select 'Oracle NetSuite' from the dropdown options.

TStep2.png

Step 9 : According to the requirements, pick the Oracle NetSuite business object from the available dropdown menu.

image.png




Note :
In case the desired business object isn't listed in the dropdown, users have the option to create both a new product and a new business object by selecting the 'Create New' option within the target name dropdown menu.


Step 10 :
After selecting the business object, all relevant details pertaining to the Oracle NetSuite API corresponding to the chosen business object will populate across the required fields within the API section.

For example, upon selecting 'Customer' as the designated business object, all pertinent information linked to the Oracle NetSuite API specifically tailored for the 'Customer' category will populate within the respective fields (Headers and Pre-request script are populated in this case)

image.png



From the image above, it's evident that the HTTP method is configured as POST, and the API endpoint URL field is populated with a value :

https://{{account_id}}.suitetalk.api.netsuite.com/services/rest/record/v1/customer

Please include all the important information about the instance you want to connect to Oracle NetSuite in the API endpoint URL.

Note : In the Headers tab, please observe that the value "{%signature%}" undergoes string interpolation. Avoid making any modifications to this value.


image.png

In body, we pass the payload which create in the Data operations section.

salesforce 9.png




image.png


In Pre-request Script tab, ensure to input all necessary details including oauth_consumer_id, oauth_consumer_key, oauth_consumer_secret, oauth_token, oauth_token_secret.

import datetime
import random
import string
import hashlib
import base64
import hmac
import urllib.parse
request_method = 'POST'
url = 'https://{{account_id}}.suitetalk.api.netsuite.com/services/rest/record/v1/customer'
oauth_consumer_id = 'xxxxxxxxxxxxxxx'    # Provide Values
oauth_consumer_key = 'xxxxxxxxxxxxxx'    # Provide Values
oauth_consumer_secret ='xxxxxxxxxxxx'    # Provide Values
oauth_token ='xxxxxxxxxxxx'              # Provide Values
oauth_token_secret ='xxxxxxxxxxxxx'      # Provide Values
oauth_signature_method = 'HMAC-SHA256'
oauth_timestamp = str(int(datetime.datetime.now().timestamp()))
oauth_nonce = ''.join(random.choices(string.ascii_letters + string.digits, k = 11))
oauth_version = '1.0'
normalized_request_method = request_method.replace(' ', '')
normalized_string_url = urllib.parse.quote(url, safe = '')
normalized_params = {'oauth_consumer_key': oauth_consumer_key,'oauth_token': oauth_token,'oauth_signature_method': oauth_signature_method,'oauth_timestamp': oauth_timestamp,'oauth_nonce': oauth_nonce,'oauth_version': oauth_version}
sorted_params = dict(sorted(normalized_params.items()))
normalized_string_parmas = [k+'='+v for k,v in sorted_params.items()]
normalized_string_parmas = '&'.join([str(elem) for elem in normalized_string_parmas])
normalized_string_parmas.replace(' ','')
normalized_string_parmas = urllib.parse.quote(normalized_string_parmas, safe = '')
base_string = request_method + '&' + normalized_string_url + '&' + normalized_string_parmas
base_string = str.encode(base_string)
signature_key = oauth_consumer_secret + '&' + oauth_token_secret
signature_key = str.encode(signature_key)
oauth_signature = hmac.new(signature_key, base_string, hashlib.sha256)
oauth_signature.hexdigest()
oauth_signature = base64.b64encode(oauth_signature.digest())
oauth_signature = oauth_signature.decode('UTF-8')
oauth_signature = urllib.parse.quote(oauth_signature, safe = '')
signature ='OAuth realm="'f'{oauth_consumer_id}",oauth_consumer_key="'f'{oauth_consumer_key}",oauth_token="'f'{oauth_token}",oauth_signature_method="'f'{oauth_signature_method}",oauth_timestamp="'f'{oauth_timestamp}",oauth_nonce="'f'{oauth_nonce}",oauth_version="'f'{oauth_version}",oauth_signature="'f'{oauth_signature}"'

After completing all the required details, the user can establish the connection to Oracle NetSuite.