Requirement:
Neutrinos needs to integrate the Master Data Employees from Adrenalin to Netsuite. Also would like to migrate existing employee records from Adrenalin to NetSuite.
Prerequisites:
Token based Authentication(TBA) is considered here as Authentication type.
So, need to set TBA( refer http://jobinandjismi.in/setting-up-netsuite-token-based-authentication-tba/ )
We will provide the consumer key, consumer secret, token ID, token secret, and adrenalin needs to generate an Authentication header to request to netsuite.
We will provide the API to get the data from adrenalin.Using a unique token ID, token key, consumer key, consumer secret, adrenalin needs to generate an Authentication header. Using this, adrenalin can send POST requests to netsuite along with the employee details structured as JSON objects that need to be created or updated in Netsuite.
Sample JSON request body:
{
“Employee id” : <Employee id>
“External id” : <Adrenalin employee internalid>
“Name”: <employee name>
“Inactive”:<true or false>
“Action-Type”:<Create or Update>
“Subsidiary”: <Netsuite Subsidiary internal id>
“Country”: <country>
“Currency”: <currency>
“Job title” : <Job title>
“Email id” : <email id>
“Sales role” : <sales role>
“Hire date” : <Hire date>
“Department” : <Netsuite Department internal id>
“Location” : <Netsuite Location internal id>
“Supervisor” : <Supervisor>
“Type” : <Type>
“Phone” : <Phone>
}
Solution :
- Developed a RESTLet script to fetch and create a file for the Data received through API Request
- Created 2 folders in the file cabinet named “Processed Files” and “To Be Processed Files”. When Adrenalin sends a POST request to Netsuite, this RESTlet will get triggered and the restlet script will fetch the employee details from the request body and store this in the “To Be Processed Files” folder.
- Developed a Map/Reduce script that fetches one request file at a time from the “To Be Processed Files” folder in the getInput stage of map/reduce script.
- After passing a request file to reduce stage, that file will be moved from “To Be Processed Files” to “Processed Files”.
- In the reduce stage, this request body is processed and based on the “Action – Type” in request, a new employee will be created in or an already existing employee will be updated in netsuite.
- “Action – Type” in request body can be either “Create” or “Update”
- If the Action type is “Create”, then a new employee will be created in netsuite with all the employee details given in the request body.
- If the Action type is “Update”, then if the “is Inactive” key’s value is “false”, then the employee is searched using the Employee ID given in the request body and then the employee record will be updated as in the request body.
- If the Action type is “Update”, then if the “is Inactive” key’s value is “true”, then the employee is searched using the Employee ID and the script will inactivate the record in netsuite.
- When an employee record is deleted or made inactive in adrenalin, a request needs to be sent to netsuite using the same format of data with “inactive” to true.
- So the script will inactivate the same record in netsuite using the employee ID.
Risks
- The currency in employee records can not be updated if once created.
- We have to turn off the auto generated number functionality for employee records. Otherwise we can not edit the employee ID in netsuite.
- For the employees that have related records, we can not change the subsidiary.
- Location of an employee cannot be changed once it is set.