Create Item
Sample Requests and Responses
The following is an example request which can be used while using ‘createItem’ action.
Request
// Create a Map to store all the data of an Item 1
Map<String, Object> nsItem1 = new Map<String, Object>();
nsItem1.put('itemType', 'nonInventoryResaleItem');
nsItem1.put('itemId', 'Leather Jacket');
nsItem1.put('taxSchedule', new Map<String, Object>{'internalId'=>'1'});
nsItem1.put('incomeAccount', new Map<String, Object>{'internalId'=>'54'});
nsItem1.put('expenseAccount', new Map<String, Object>{'internalId'=>'58'});
nsItem1.put('salesDescription', 'Blue Color Leather Jacket');
// Provide the Subsidiary List
List<Object> subsidiaryList1 = new List<Object>{new Map<String, Object>{'internalId'=>'1'}};
nsItem1.put('subsidiaryList', new Map<String, Object>{'recordRef'=>subsidiaryList1});
nsItem1.put('includeChildren', TRUE);
// Initializing the Item Custom Fields
List<Object> itemCustomFieldList = new List<Object>();
Map<String,Object> itemCustomField = new Map<String,Object>();
itemCustomField.put('fieldType', 'select');
itemCustomField.put('scriptId', 'custitem_standardlist');
itemCustomField.put('valueLookup', new Map<String,Object>{'internalId'=>'2'});
itemCustomFieldList.add(itemCustomField);
Map<String,Object> itemCustomField1 = new Map<String,Object>();
itemCustomField1.put('fieldType', 'boolean');
itemCustomField1.put('scriptId', 'custitem_checkbox');
itemCustomField1.put('value','true');
itemCustomFieldList.add(itemCustomField1);
// Adding the Item Custom Fields
nsItem1.put('customFieldList', new Map<String,Object>{'customField'=>itemCustomFieldList});
// Create a Map to store all the data of an Item 2
Map<String, Object> nsItem2 = new Map<String, Object>();
nsItem2.put('itemType', 'nonInventorySaleItem');
nsItem2.put('itemId', 'Laptop');
nsItem2.put('taxSchedule', new Map<String, Object>{'internalId'=>'1'});
// Provide the Subsidiary List
List<Object> subsidiaryList2 = new List<Object>{new Map<String, Object>{'internalId'=>'1'}};
nsItem2.put('subsidiaryList', new Map<String, Object>{'recordRef'=>subsidiaryList2});
// Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
requestJSONMap.put('items', new List<Object>{nsItem1, nsItem2}); // similarly we can upto 20 items to the list
String reqJSON = JSON.serialize(requestJSONMap);
Map<String, Object> reqObj = new Map<String, Object>();
reqObj.put('version', '1.0');
reqObj.put('action', 'createItem');
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=createItem,
timestamp=1606829457729,
validRequest=true,
version=1.0,
responseJSON={
"status": "200",
"errors": [],
"items": [
{
"useMarginalRates": false,
"unitsType": null,
"taxSchedule": {
"name": "Default Tax-Schedule",
"internalId": "1"
},
"subsidiaryList": {
"recordRef": [
{
"type": null,
"name": "Parent Company",
"internalId": "1",
"externalId": null
}
]
},
"shippingCost": null,
"salesforceId": "a082w0000072U8hAAE",
"salesDescription": "Blue Color Leather Jacket",
"rate": null,
"quantityPricingSchedule": null,
"purchaseDescription": null,
"pricingMatrix": null,
"pricingGroup": null,
"preferredLocation": null,
"parent": null,
"overallQuantityPricingType": "_byLineQuantity",
"minimumQuantity": null,
"memberList": null,
"maximumQuantity": null,
"matrixType": null,
"locationsList": null,
"location": null,
"lastModifiedDate": 1606829455,
"itemType": "NonInventoryResaleItem",
"itemId": "Leather Jacket",
"isInactive": false,
"internalId": "7718",
"incomeAccount": {
"type": null,
"name": "Sales",
"internalId": "54",
"externalId": null
},
"includeChildren": true,
"handlingCost": null,
"externalId": null,
"expenseAccount": {
"type": null,
"name": "Expenses",
"internalId": "58",
"externalId": null
},
"displayName": null,
"description": null,
"department": null,
"customForm": {
"type": null,
"name": "Custom Non-Inventory Part Form",
"internalId": "5",
"externalId": null
},
"customFieldList": {
"customField": [
{
"valueLookup": {
"type": null,
"name": "Retailer",
"internalId": "2",
"externalId": null
},
"value": null,
"scriptId": "custitem_standardlist",
"internalId": "457",
"fieldType": null
},
{
"valueLookup": null,
"value": "true",
"scriptId": "custitem_checkbox",
"internalId": "250",
"fieldType": null
}
]
},
"currencyValue": "1",
"createdDate": 1606829455,
"cost": null,
"cogsAccount": null,
"classification": null,
"assetAccount": null,
"account": null
},
{
"useMarginalRates": false,
"unitsType": null,
"taxSchedule": {
"name": "Default Tax-Schedule",
"internalId": "1"
},
"subsidiaryList": {
"recordRef": [
{
"type": null,
"name": "Parent Company",
"internalId": "1",
"externalId": null
}
]
},
"shippingCost": null,
"salesforceId": "a082w0000072U8iAAE",
"salesDescription": null,
"rate": null,
"quantityPricingSchedule": null,
"purchaseDescription": null,
"pricingMatrix": null,
"pricingGroup": null,
"preferredLocation": null,
"parent": null,
"overallQuantityPricingType": "_byLineQuantity",
"minimumQuantity": null,
"memberList": null,
"maximumQuantity": null,
"matrixType": null,
"locationsList": null,
"location": null,
"lastModifiedDate": 1606829456,
"itemType": "NonInventorySaleItem",
"itemId": "Laptop",
"isInactive": false,
"internalId": "7719",
"incomeAccount": {
"type": null,
"name": "Sales",
"internalId": "54",
"externalId": null
},
"includeChildren": false,
"handlingCost": null,
"externalId": null,
"expenseAccount": null,
"displayName": null,
"description": null,
"department": null,
"customForm": {
"type": null,
"name": "Custom Non-Inventory Part Form",
"internalId": "5",
"externalId": null
},
"customFieldList": {
"customField": [
{
"valueLookup": null,
"value": "false",
"scriptId": "custitem_checkbox",
"internalId": "250",
"fieldType": null
}
]
},
"currencyValue": null,
"createdDate": 1606829456,
"cost": null,
"cogsAccount": null,
"classification": null,
"assetAccount": null,
"account": null
}
]
}
}