Create Return Authorization
Sample Requests and Responses
The following is an example request which can be used while using ‘createReturnAuthorization’ action.
Request
// Create a Map to store all the data of a RMA
Map<String, Object> nsRMA = new Map<String, Object>();
nsRMA.put('classification', new Map<String, Object>{'internalId'=>'1'});
nsRMA.put('currencyRecord', new Map<String, Object>{'internalId'=>'1'});
nsRMA.put('department', new Map<String, Object>{'internalId'=>'1'});
nsRMA.put('discountItem', new Map<String, Object>{'internalId'=>'-6'});
nsRMA.put('discountRate', '-15');
nsRMA.put('entity', new Map<String, Object>{'internalId'=>'362'});
nsRMA.put('memo', 'Order 25');
nsRMA.put('otherRefNum', '4343399');
nsRMA.put('tranDate', DateTime.newInstance(2020, 09, 07).getTime()/1000);
// Initializing the RMA Custom Fields
List<Object> rmaCustomFieldList = new List<Object>();
Map<String,Object> rmaCustomField = new Map<String,Object>();
rmaCustomField.put('fieldType', 'select');
rmaCustomField.put('scriptId', 'custbody_customlist');
rmaCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
rmaCustomFieldList.add(rmaCustomField);
// Adding the RMA Custom Fields
nsRMA.put('customFieldList', new Map<String,Object>{'customField'=>rmaCustomFieldList});
// Initializing the RMA Line Items
List<Object> lineItemList = new List<Object>();
Map<String, Object> lineItem = new Map<String, Object>();
lineItem.put('description', 'A weapon for shooting arrows');
lineItem.put('item', new Map<String, Object>{'internalId'=>'239'});
lineItem.put('quantity', 1);
// Initializing the Line Item custom fields
List<Object> liCustomFieldList = new List<Object>();
Map<String, Object> liCustomField = new Map<String, Object>();
liCustomField.put('fieldType', 'boolean');
liCustomField.put('scriptId', 'custbody_checkbox');
liCustomField.put('value', 'true');
liCustomFieldList.add(liCustomField);
// Adding the RMA Line Item Custom Fields
lineItem.put('customFieldList',new Map<String,Object>{'customField'=>liCustomFieldList});
lineItemList.add(lineItem);
// Adding the Line Items to RMA
Map<String, Object> rmaLineitemList = new Map<String, Object>();
rmaLineitemList.put('item',lineItemList);
nsRMA.put('itemList',rmaLineitemList);
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('returnAuthorizations', new List<Object>{nsRMA});
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'createReturnAuthorization');
reqObj.put('requestJSON', reqJSON);
// Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);
System.debug(resp);
Response
{
action = createReturnAuthorization,
timestamp = 1613541991118,
validRequest = true,
version = 1.0,
responseJSON = {
"status": "200",
"errors": [],
"returnAuthorizations": [
{
"tranId": "65",
"tranDate": 1599447600,
"totalCostEstimate": null,
"total": 85,
"taxTotal": 0,
"subTotal": 100,
"subsidiary": {
"type": null,
"name": "Parent Company",
"internalId": "1",
"externalId": null
},
"status": "Pending Receipt",
"source": "Web Services",
"salesRep": null,
"salesforceID": "a0L4x000000miYbEAI",
"salesEffectiveDate": 1599447600,
"otherRefNum": "4343399",
"orderStatus": "_pendingReceipt",
"nullFieldList": null,
"memo": "Order 25",
"location": null,
"lastModifiedDate": 1613541969,
"itemList": {
"replaceAll": null,
"item": [
{
"unitsDisplay": null,
"taxRate1": "0.0",
"taxCode": {
"type": null,
"name": "VAT_IN:UNDEF-IN",
"internalId": "5",
"externalId": null
},
"tax1Amt": 0,
"shipMethod": null,
"shipGroup": null,
"serialNumbers": null,
"revRecStartDate": null,
"revRecSchedule": null,
"revRecEndDate": null,
"rate": "100.00",
"quantityRemaining": null,
"quantityReceived": 0,
"quantityBilled": 0,
"quantity": 1,
"price": {
"type": null,
"name": "Base Price",
"internalId": "1",
"externalId": null
},
"poNum": null,
"orderLine": null,
"onHand": null,
"location": null,
"line": 1,
"jobName": null,
"itemReceive": null,
"itemName": null,
"itemIsFulfilled": null,
"item": {
"type": null,
"name": "Bow",
"internalId": "239",
"externalId": null
},
"grossAmt": 100,
"expectedReceiptDate": null,
"description": "A weapon for shooting arrows",
"department": null,
"customFieldList": {
"customField": [
{
valueLookup": null,
"value": "1",
"scriptId": "custcol_gh_line_no",
"internalId": "175",
"fieldType": null
},
{
"valueLookup": null,
"value": "12320000000000117_72960",
"scriptId": "custcol_gh_so_line_id",
"internalId": "200",
"fieldType": null
},
{
"valueLookup": null,
"value": "false",
"scriptId": "custcol_checkbox",
"internalId": "443",
"fieldType": null
}
]
},
"createPo": null,
"costEstimateType": null,
"costEstimate": null,
"classification": null,
"amount": 100
}
]
},
"internalId": "70374",
"externalId": null,
"entity": {
"type": null,
"name": "21 Atherton Grocery",
"internalId": "362",
"externalId": null
},
"discountTotal": -15,
"discountRate": "-15.00",
"discountItem": {
"type": null,
"name": "Partner Discount",
"internalId": "-6",
"externalId": null
},
"department": {
"type": null,
"name": "PR Department",
"internalId": "1",
"externalId": null
},
"customForm": {
"type": null,
"name": "Custom Return Authorization - Credit",
"internalId": "109",
"externalId": null
},
"customFieldList": {
"customField": [
{
"valueLookup": {
"type": null,
"name": "B",
"internalId": "2",
"externalId": null
},
"value": null,
"scriptId": "custbody_customlist",
"internalId": "458",
"fieldType": null
},
{
"valueLookup": null,
"value": "false",
"scriptId": "custbody_checkbox",
"internalId": "272",
"fieldType": null
}
]
},
"currencyRecord": null,
"currencyName": "INR",
"createdFrom": null,
"createdDate": 1613541969,
"classification": {
"type": null,
"name": "Partner Class",
"internalId": "1",
"externalId": null
}
}
]
}
}