No Code Salesforce and NetSuite Integration

Apphienz
4 min readApr 6, 2023

The first cloud computing software provider is recognized to be NetSuite. You can manage your sales process more effectively with real-time access to your back office thanks to the automatic, real-time connection between Salesforce and NetSuite, which also eliminates data entry tasks, cost overhead, and data duplication.

In this blog, we will go over the features, benefits, prerequisites, and No Code Salesforce and NetSuite integration process;

Features of Salesforce and NetSuite

360-Degree Visibility

Track the processing of sales orders or keep track of consumer financial activities like credits and refunds in real-time.

Numerous Customizations

By including the capabilities that are most beneficial for your organization, you can make your integration work for you.

Extra Features

Enhance efficiency by synchronizing order cancellations, removing items from the store, etc.

Unified Product Information

Real-time product export from NetSuite to Salesforce will provide your sales team access to the most recent product information.

Standardized product pricing levels

Easily synchronize product price, numerous pricing tiers, and support for multiple currencies between NetSuite and Salesforce

Real-time Sales Order Synchronization

Create quotes and sales orders in NetSuite in real-time from won or closed Salesforce opportunities while automatically syncing the relevant data.

Easy to deploy

Immediately deploy to get you moving with the least amount of fuss

Prerequisites

  • One’s Salesforce profile.
  • A NetSuite profile.
  • Working knowledge of NetSuite and Salesforce

Benefits of Salesforce and Netsuite Integartion

  • An improvement in productivity and cash flow efficiency
  • Improve Processes
  • Get Vital Customer Data
  • Accuracy of Data
  • Dashboards & Reports for 360° Financial Visibility

Integration Process

Make Restlet scripts and add them to the NetSuite platform.

A JS script for adding new fields is added to NetSuite as the first step in the NetSuite Salesforce Integration. The following code is necessary to create a new contact (as you must add a new script file for each object you want to synchronize between NetSuite and Salesforce).

// Create a standard NetSuite record

function createRecord(datain)

{

var err = new Object();

// Validate if mandatory record type is set in the request

if (!datain.recordtype)

{

err.status = “failed”;

err.message= “missing recordtype”;

return err;

}

var record = nlapiCreateRecord(datain.recordtype);

for (var fieldname in datain)

{

if (datain.hasOwnProperty(fieldname))

{

if (fieldname != ‘recordtype’ && fieldname != ‘id’)

{

var value = datain[fieldname];

if (value && typeof value != ‘object’) // ignore other type of parameters

{

record.setFieldValue(fieldname, value);

}

}

}

}

nlapiLogExecution(‘DEBUG’,’zip=’+datain.zip);

record.selectNewLineItem(‘addressbook’);

record.setCurrentLineItemValue(‘addressbook’,’city’, datain.city);

record.setCurrentLineItemValue(‘addressbook’,’zip’, datain.zip);

record.setCurrentLineItemValue(‘addressbook’, ‘country’, ‘US’);

record.setCurrentLineItemValue(‘addressbook’,’label’,’billing address’);

record.commitLineItem(‘addressbook’);

record.selectNewLineItem(‘contact’);

record.setCurrentLineItemValue(‘contact’,’contactrole’,’-10′);

record.setCurrentLineItemValue(‘contact’, ‘firstname’, datain.firstname);

record.commitLineItem(‘contact’);

var recordId = nlapiSubmitRecord(record);

nlapiLogExecution(‘DEBUG’,’id=’+recordId);

var nlobj = nlapiLoadRecord(datain.recordtype,recordId);

return nlobj;

}

Salesforce Account Authentication for NetSuite

Authentication is necessary for all data transfers. To authenticate the NetSuite account for Salesforce, see the sample script in the code below. The majority of times when NetSuite and Salesforce are integrated, it is advisable to carry out the authentication calls using NetSuite credentials and utilize Salesforce to access or transfer data to NetSuite.

public static void createNSCustomerRecord(account acc){

HttpRequest req = new HttpRequest();

HttpResponse res = new HttpResponse();

String endpoint = currNetSuiteSettings.NSEndpointCreateCustomer__c;

req.setEndpoint(endpoint);

string custId;

//Set Method and Endpoint and Body

req.setMethod(‘POST’);

req.setTimeout(119990);

Http http = new Http();

String responseBody;

req.setHeader(‘Content-Type’,’application/json’);

string NetSuiteProductionAccount = currNetSuiteSettings.NetSuiteProductionAccount__c;

string NetSuiteProductionUserName = currNetSuiteSettings.NetSuiteProductionUserName__c;

string NetSuiteProductionPassword = currNetSuiteSettings.NetSuiteProductionPassword__c;

String authorizationheader = ‘NLAuth nlauth_account=’+NetSuiteProductionAccount+’,

nlauth_email=’+NetSuiteProductionUserName+’,nlauth_signature=’;

nlauth_email= nlauth_email+NetSuiteProductionPassword;

//Construct Authorization and Content header

req.setHeader(‘Authorization’, authorizationHeader);

string recordType = ‘customer’;

string accountId = ”;

accountId = acc.Id;

system.debug(‘accountId===>’+accountId);

//you need the minimum field pattern for whatever entity you are posting, refer to their API guide

req.setBody

(‘{“recordtype”:”‘+recordType+’”,”entityid”:”‘+acc.name+’”,”accountId”:”‘+accountId+’”);

system.debug(‘setBody’+req);

try {

res = http.send(req);

responseBody = res.getBody();

system.debug(‘responseBody’+responseBody

JSONParser parser = JSON.createParser(responseBody );

while (parser.nextToken() != null) {

System.debug(‘Current token: ‘ + parser.getCurrentToken());

// Advance to the next value.

parser.nextValue();

// Get the field name for the current value.

String fieldName = parser.getCurrentName();

if(fieldName == ‘id’)

{

// Get the textual representation of the value.

System.debug(‘fieldName ==id’);

custId = parser.getText();

system.debug(‘custId====>’+custId);

break;

}

}

try {

List <account> acc1 = [select NetSuiteCustomerId__c from account where id= :acc.id];

if(acc1.isEmpty() == false) {

acc1[0].NetSuiteCustomerId__c = custId;

update acc1;

}

} catch(System.CalloutException e) {

System.debug(‘Callout error: ‘+ e);

}

} catch(System.CalloutException e) {System.debug(res.toString());}

}

Execute Classes Between Salesforce and NetSuite in Batches

Although the entire sync procedure can be carried out in real-time, running it in batches is the ideal choice. To make and execute these batches, use the following code.

global class NetSuiteBatchApexWebCalloutClass Implements Database.Batchable<account>, Database.AllowsCallouts{global List<account> accountsToTarget;

private NetSuiteBatchApexWebCalloutClass(){}

Global NetSuiteBatchApexWebCalloutClass(Set<String> accRecIds)

{

accountsToTarget = [SELECT Id, Name,owner.Name,NetSuiteCustomerId__c FROM Account where Id IN : accRecIds];

}global Iterable<account> start(database.batchablecontext BC){

return (accountsToTarget);

}

global void execute(Database.BatchableContext BC, List<account> scope){

for(Account a : scope){

NetSuiteWebserviceCallout.createNSCustomerRecord(a);

}

}

global void finish(Database.BatchableContext info){ }//global void finish loop

}

Voila! Salesforce and NetSuite and integrated seamlessly. If you are looking to integrate Salesforce with third-party apps, look no further and get in touch with our seasoned experts at Apphienz. We are rated amongst the top Salesforce partners providing personalized and customized Salesforce services like Managed services and support, Salesforce integrations, Salesforce app development, etc.

Visit our website to know more about us and get in touch with us in case of any further queries. We will get back to you at the earliest.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Apphienz
Apphienz

Written by Apphienz

Your Salesforce partner from Inception to Support

No responses yet

Write a response