Proposal summary
Need to create sales orders using custom API.
Requirement
Need to implement a RESTLet API for creating sales orders.
Our Solution
Prerequisites
– Swift needs to grant edit and create access to the sales order.
Description of the task
The requirement can be achieved by creating a RESTlet. The RESTlet API will access the body as given below.
{
“type”: ‘<record type>’,// sample value : salesorder
“customerId”: ‘<customer internalid>’,// sample value : customer internalid
“items”: [{
“itemid”: ‘<item internal id>’, // sample value : item internalid (mandatory)
“quantity”: ‘<Item sku name>’, // sample value : item quantity (mandatory)
“Amount”: ‘<Item amount>’, // sample value : item amount (mandatory)
“taxCode”: ‘<tax code internal id>’, // sample value : tax code internalid (not mandatory)
“taxCodeText”: ‘<tax code text>’, // sample value : tax code text (not mandatory)
}, {
“itemid”: ‘<item internal id>’, // sample value : item internalid (mandatory)
“quantity”: ‘<Item sku name>’, // sample value : item quantity (mandatory)
“Amount”: ‘<Item amount>’, // sample value : item amount (mandatory)
“taxCode”: ‘<tax code internal id>’, // sample value : tax code internalid (not mandatory)
“taxCodeText”: ‘<tax code text>’, // sample value : tax code text (not mandatory)
}]
}
We will create a sales order using the data from RESTlet request body data.
- If the items array in the request body is empty, We will not create a sales order for this request.
- We create sales orders. Only when the customerId is present in the request body.
- If the item datil the following values are mandatory (itemid/quantity/Amount). If any of the values is null/empty we do not consider such items in the sales order creation.
- If any error in sales order creation will occur we will return the sales order status and return the errors in response and not create the sales order for this request.
- {status: “”, message:””,response:””}
- The above content will be the RESTlet API response.
- The tax code is not mandatory. If the taxCode/taxCodeText is present in the item array. We will create sales order’s line items using this value. Else we will use by default value to populate netsuite itself.
Notes
- Only one sales order can be created on one request.
- The request URL will be new as a new RESTlet will be created only for this functionality.
- First we will implement this in a sandbox environment / after we will move it into production.
- It will be great to provide admin access in the sandbox environment.
Additional Information
1) For implementing this sales order creation using RESTlet API. We need a set of data.
Consumer key
Consumer secret
Token id
Token secret.