website logo
Product Overview
NetSuite
Payments
QuickBooks
Xero
Navigate through spaces
⌘K
General Concepts
What is Breadwinner
Getting Started
App Installation
Initial Configuration
Person Accounts
Company Matching
Product Matching
NetSuite Items and Item Groups
Download PDF button
Weekly Sync Timeframe
Security and Permissions
NetSuite Permissions
Custom Guided Wizard
Quick Create Sales Order
Button URL Structure
NetSuite Company Creation
Button URL Generator
Support
Custom Fields
Custom Objects
Global API
Quick Start Guide
API Overview
Requests
Response
Apex Generator
Code Examples
Advanced Topics
Formula Fields
NetSuite Discounts
NetSuite Payment Terms
Memorized Transactions
Sync Data Filtering
Technical Resources
Deploy Plan
Requirements
ERD / Object Structure
Getting Help
Version History
Direct Installation Link
Docs powered by
Archbee
Global API
...
Requests
Item

Create

1min

The following is an example of creating an Item where we are setting every possible field (See Item for the available fields). The response will return the exact request data plus the new NetSuite item Id (internalId) and the newly created Salesforce item Id (salesforceID).

Pass skipDML as true in the request to skip the DML operation in Salesforce.

Request
Response
|
//  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);






Updated 20 Apr 2023
Did this page help you?
PREVIOUS
Read
NEXT
Update
Docs powered by
Archbee
Docs powered by
Archbee