SalesForce NetSuite Integration through Restlet GGBN

Proposal Summary 

This proposal outlines the extent of the integration process, which involves generating Sales Orders and Credit Memo records. This integration will synchronize the tax code and tax amount at the line item level in NetSuite using the REST API. 

Requirement 

Growire requires an integration connecting Salesforce with NetSuite, enabling the generation of Sales Orders and Credit Memo records. This integration will ensure the synchronization of tax codes and tax amounts within NetSuite each time Salesforce triggers the REST API. 

Deliverable 

We will develop three RESTlet scripts within NetSuite. These scripts will facilitate the creation of APIs, allowing NetSuite to receive POST requests from Salesforce to generate Sales Orders and Credit Memo records in real time. 

Sales Order Creation 

The table data below outlines the request parameters that the NetSuite API can accept for the creation of the sales orders. 

JSON Request Field  NetSuite Field  Internal ID  Description/Default Values  
recordType TYPE recordType Salesorder 
customerID CUSTOMER: PROJECT  entity Internal id of the customer. 
date DATE trandate The date range in which this transaction should appear on the Sales Order Register. 
status STATUS orderstatus Default status for the sales orders. If Growire uses the approval process for sales orders, then Pending Approval or Pending Fulfillment. 
Location       LOCATION location Location to associate with this transaction. 
currency CURRENCY   currency Internal ID of the transaction currency to create this transaction in. 
subsidiary SUBSIDIARY subsidiary Internal ID of the subsidiary. 
exchangeRate EXCHANGE RATE exchangerate Currency’s exchange rate 
Item_id ITEM item Item internal ID 
quantity QUANTITY quantity Quantity for the item 
taxCode TAX CODE taxcode Inernal ID of the tax code 
taxamount TAX AMOUNT tax1amt Tax amount 

SAMPLE REQUEST FORMAT  

Salesorder:{ 

    “currency”: 4, 

    “custbody_document_date”: “2023-08-07”, 

    “custbody_ota_documentpdflink”: “https://otainsight–uat.sandbox.my.salesforce.com/sfc/p/1q0000004rtu/a/1q0000001sLj/z.ba.Xzu7fprqshG6kMMlgF1DIRaeyodiEJMzdOvPnU”, 

    “custbody_ota_salesforcerecordid”: “a4S1q000000RFrkEAG”, 

    “custbody_ota_salesforceupdateddate”: “2023-08-07T09:54:30.000Z”, 

    “custbody_ota_salesforceurl”: “https://otainsight–uat.sandbox.my.salesforce.com/a4S1q000000RFrkEAG”, 

    “custbody_ota_sfsyncheddate”: “2023-08-11T11:05:49.130Z”, 

    “custbody_ota_transactionemailsentdate”: “2023-08-07T09:54:30.000Z”, 

    “dueDate”: “2023-09-06”, 

    “entity”: 127901, 

    “externalId”: “a4S1q000000RFrkEAG”, 

    “item”: { 

        “items”: [ 

            { 

                “rate”: 200.00, 

                “item”: 2646, 

                “quantity”: 1.00, 

                “custcol_ota_serviceperiodenddate”: “2023-08-07”, 

                ” custcol_ota_serviceperiodstartdate “: “2023-08-07” 

            }, 

            { 

                “rate”: -100.00, 

                “item”: 2647, 

                “quantity”: 1.00, 

                “custcol_ota_serviceperiodenddate”: “2023-08-07”, 

                “custcol_ota_serviceperiodstartdate”: “2023-08-07” 

            }, 

            { 

                “rate”: -50.00, 

                “item”: 2386, 

                “quantity”: 1.00, 

                “custcol_ota_serviceperiodenddate”: “2023-08-07”, 

                “custcol_ota_serviceperiodstartdate”: “2023-08-07” 

            } 

        ] 

    }, 

    “memo”: null, 

    “subsidiary”: 1, 

    “tranDate”: “2023-08-07”, 

    “tranId”: “INV00000127” 

} 

RESPONSE AND ERROR MESSAGE  

Response for Sales order creation in NetSuite will contain following fields:  

JSON Response Field  Description  
statusCode  Response status as Success or Failure   
Response message  If statusCode is success record id of created Sales order. 
Error message  NetSuite error or standard message if the statusCode is failure  

SAMPLE RESPONSE FORMAT  

{  
    “statusCode”: “SUCCESS”,  
    “recordId”: 546,  
}  

{  
    “statusCode”: “FAILURE”,  
    “error”: “date is mandatory”,  
}  

Response Status Codes:  

SUCCESS  

FAILURE  

Credit Memo Creation 

The table data below outlines the request parameters that the NetSuite API can accept for the creation of the Credit Memos. 

JSON Request Field  NetSuite Field  Internal ID  Description/Default Values  
recordType TYPE recordType creditmemo 
customerID CUSTOMER: PROJECT  entity Internal id of the customer. 
date DATE trandate The date range in which this transaction should appear on the Sales Order Register. 
Location       LOCATION location Location to associate with this transaction. 
currency CURRENCY   currency Internal ID of the transaction currency to create this transaction in. 
subsidiary SUBSIDIARY subsidiary Internal ID of the subsidiary. 
exchangeRate EXCHANGE RATE exchangerate Currency’s exchange rate 
Item_id ITEM item Item internal ID 
quantity QUANTITY quantity Quantity for the item 
taxCode TAX CODE taxcode Inernal ID of the tax code 
taxamount TAX AMOUNT tax1amt Tax amount 

SAMPLE REQUEST FORMAT  
 
Credit Note: { 

 “currency”: 4, 

 “custbody_document_date”: “2023-08-03”, 

“custbody_ota_documentpdflink”: “https://otainsight–uat.sandbox.my.salesforce.com/sfc/p/1q0000004rtu/a/1q0000001s4Y/wGLQSXOdh5MCwinKXbsD6UWY_2XJb2hLoY5tEUg3Xl0”, 

    “custbody_ota_salesforcerecordid”: “a4B1q000006LeZUEA0”, 

 “custbody_ota_salesforceupdateddate”: “2023-08-03T14:07:04.000Z”, 

“custbody_ota_salesforceurl”:”https://otainsight–uat.sandbox.my.salesforce.com/a4B1q000006LeZUEA0″, 

    “custbody_ota_sfsyncheddate”: “2023-08-11T11:06:19.659Z”, 

    “custbody_ota_transactionemailsentdate”: “2023-08-03T14:07:04.000Z”, 

    “custcol_ota_serviceperiodenddate”: null, 

    “custcol_ota_serviceperiodstartdate”: null, 

    “entity”: 119894, 

    “externalId”: “a4B1q000006LeZUEA0”, 

    “item”: { 

        “items”: [ 

            { 

                “rate”: 0, 

                “item”: 2590, 

                “quantity”: 3.00, 

                “custcol_ota_serviceperiodenddate”: “2024-08-02”, 

                “custcol_ota_serviceperiodstartdate”: “2023-08-03” 

            }, 

            { 

                “rate”: 0, 

                “item”: 3070, 

                “quantity”: 3.00, 

                “custcol_ota_serviceperiodenddate”: “2024-08-02”, 

                “custcol_ota_serviceperiodstartdate”: “2023-08-03” 

            }, 

            { 

                “rate”: 1536, 

                “item”: 2639, 

                “quantity”: 3.00, 

                “custcol_ota_serviceperiodenddate”: “2024-08-02”, 

                “custcol_ota_serviceperiodstartdate”: “2023-08-03” 

            } 

        ] 

    }, 

    “memo”: null, 

    “subsidiary”: 1, 

    “tranDate”: “2023-08-03”, 

    “tranId”: “CN00000030” 

} 

RESPONSE AND ERROR MESSAGE  

Response for Sales order creation in NetSuite will contain following fields:  

JSON Response Field  Description  
taxamount   
  
  

SAMPLE RESPONSE FORMAT  

{  
    “statusCode”: “SUCCESS”,  
    “recordId”: 546,  
}  

{  
    “statusCode”: “FAILURE”,  
    “error”: “date is mandatory”,  
}  

Response Status Codes:  

SUCCESS  

FAILURE 

Error handling and email notification  

We will be creating a custom record for tracking errors that happen during API requests. It will be used for both APIs sales orders and credit memos. And we will be notifying the administrator using email notification with the custom record link. 

Authorization 

API credentials will be shared to the Application user to send request to NetSuite. The Integration record will be created in the NetSuite with Auth 1.0 credentials. The token will be generated for the customized role. 

Steps in customized role setup:   

  • “External API User” role will be created in the account for the user to Use the API with limited permissions.  
  •  Employee records will be created for the external API user.   
  •  Integration role will be added to the new user.   
  •  Token will be generated for the new customised role. 

Assumptions 

The proposed solution is based on the following assumptions: 

  • We will only be creating POST request APIs for the creation of the tarnsaction  records in NetSuite and we are not updating the already created records.  
  • We will be validating all the mandatory fields for the creation of Sales Orders and Credit Memo records.  
  • Deletion of the records are out of scope.  
  • We will be creating a custom record for only error handling in NetSuite if the request is failed. If the request is success, we will not be creating any custom record entry.  
  • We are creating record with active state and inactive records will be out of scope.  
  • Inactivating fields and changing field type is out of scope.  
  • Request data should be in JSON format.  
  • Only one record will be created for a single request. Growire can initiate separate request per record.  
  • Duplication detection of records out of scope.  
  • Posting periods inside the tarnsactions will be sourced based on the date. 
  • It is expected that the customer already exists within the NetSuite platform. 
  • Item mappings will be executed using the distinct internal ID of each individual item. 
  • Two endpoints will be established for the purpose of creating Sales Orders and Credit Memos. 

Risks 

  • Restlet script characteristics  

5,000 usage units per script. 

Maximum 10MB per string used as RESTlet input or output. 

  • Currently, we are excluding the consideration of custom fields. Our investigation within the provided test environment indicates the absence of the custom fields mentioned in the provided REST API content. Therefore, we will proceed with the scope, focusing on the standard mandatory fields of the given environment. 

Questions 

The custom fields should be included in the scope of the assignment. The rest api call request samples that I have sent should be handled by the script fully. we will migrate the custom fields to the test environment by Monday’s EOB. – Yes, we will ensure the custom fields are included as well. Also, we look forward to the custom fields being migrated to the test environment by Monday’s EOB. 

Response messages from the restlet should be the same as from OOTB rest api call. – Got it. We’ll ensure our response format aligns with the recommended approach for the rest API call. To proceed effectively, could you please share the responses you currently receive from the OOTB rest API call? 

How the Integration record will be created in NetSuite is not yet final, but does this have an impact on the restlet development? – No, it will not significantly impact the development of the restlet scripts. 

For testing purposes, we have initiated the creation of an integration record to generate credentials using our assigned role. This will facilitate testing from our end. 

Usage: on january 1, 3500 invoices are scheduled, which is considered to be the most heavy load at this moment – Thank you for providing this insight. We will incorporate this information into our planning moving forward. 

Based on Assumptions: 

We will only be creating POST request APIs for the creation of the tarnsaction records in NetSuite and we are not updating the already created records. OK 

We will be validating all the mandatory fields for the creation of Sales Orders and Credit Memo records. OK 

Deletion of the records are out of scope. OK 

We will be creating a custom record for only error handling in NetSuite if the request is failed. If the request is success, we will not be creating any custom record entry. OK 

We are creating record with active state and inactive records will be out of scope. – What do you mean? – We assure you that we will only create records, including custom records for errors, in an active state. Inactive records will not be generated as part of our process. 

Inactivating fields and changing field type is out of scope. OK 

Request data should be in JSON format. OK 

Only one record will be created for a single request. Growire can initiate separate request per record. – seems ok, but what exactly do you mean?  
Multiple requests can be made for the creation of different records. 

Duplication detection of records out of scope. OK 

Posting periods inside the tarnsactions will be sourced based on the date. – is the normal logic of NetSuite not applied? 
Certainly, in most cases, NetSuite standards will manage this process. However, if any complexities arise, the script will be utilized to address them. 

It is expected that the customer already exists within the NetSuite platform. OK, if customer does not exits, the record can not be created and an error message is to be stored. 

Item mappings will be executed using the distinct internal ID of each individual item. OK 

Two endpoints will be established for the purpose of creating Sales Orders and Credit Memos.  Yes, InternalId is used. 

Leave a comment

Your email address will not be published. Required fields are marked *