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
Onboarding
Security and Permissions
NetSuite Permissions
Custom Guided Wizard
Quick Create Sales Order
Button URL Structure
NetSuite Company Creation
Button URL Generator
Support
Custom Fields
Manual Creation in Salesforce
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
REST API
Getting Help
Version History
Direct Installation Link
Docs powered by Archbee
Global API
...
Requests
Contact

Create

1min

To create a Contact in NetSuite, use action as "createContact" and pass the Contact data in the requestJSON under "contacts".

Note: You can only create one record at a time.

The following is an example of createContact where we are setting most of the fields (See Contact for all the available fields). The response will return the response back from NetSuite, which includes the new NetSuite Contact Id (internalId), plus the newly created Salesforce Contact Id (salesforceID)

Request
Response
 //  Create a Map to store all the data of a Contact
Map<String, Object> nsContact = new Map<String, Object>();
    nsContact.put('firstName', 'James');
    nsContact.put('lastName','Williams');
    nsContact.put('subsidiary', new Map<String, Object>{'internalId'=>'1'});
    nsContact.put('email', 'james@grandhotel.com');
    nsContact.put('company', new Map<String, Object>{'internalId'=>'32342'});
    nsContact.put('phone', '3453254543');
    nsContact.put('officePhone', '6546564564');
    nsContact.put('title', 'CEO');
    nsContact.put('isPrivate', true);

//  Initializing the Contact Custom Fields
    List<Object> conCustomFieldList = new List<Object>();
    Map<String, Object> conCustomField1 = new Map<String, Object>();
        conCustomField1.put('fieldType', 'boolean');
        conCustomField1.put('scriptId', 'custentity_f3_mm_send_wf_sms');
        conCustomField1.put('value', 'true');
        conCustomFieldList.add(conCustomField1);
    Map<String, Object> conCustomField2 = new Map<String, Object>();
        conCustomField2.put('fieldType', 'string');
        conCustomField2.put('scriptId', 'custentity_alt1_email');
        conCustomField2.put('value', 'james12@gmail.com');
        conCustomFieldList.add(conCustomField2);

//  Adding the Contact Custom Fields
    nsContact.put('customFieldList', new Map<String, Object>{'customField'=>conCustomFieldList});

//  Initializing the Contact Addresses
    List<Object> addressBookList = new List<Object>();
    Map<String, Object> addressBook = new Map<String, Object>();
    Map<String, Object> addressbookAddress = new Map<String, Object>();
        addressbookAddress.put('addr1', 'Suite 201');
        addressbookAddress.put('addr2', '2334 Park Street Avenue');
        addressbookAddress.put('city', 'Chicago');
        addressbookAddress.put('state', 'IL');
        addressbookAddress.put('country', '_unitedStates');
        addressbookAddress.put('zip', '60601');
        
        addressBook.put('addressbookAddress', addressbookAddress);
        addressBook.put('defaultBilling', true);
        addressBook.put('defaultShipping', true);
        
        addressBookList.add(addressBook);
    
    nsContact.put('addressbookList', new Map<String, Object>{'addressbook'=>addressBookList}); 

//  Initializing the RequestJSON Data to be passed.
Map<String, Object> requestJSONMap = new Map<String, Object>();
    requestJSONMap.put('contacts', new List<Object>{nsContact});
    String reqJSON = JSON.serialize(requestJSONMap);

Map<String, Object> reqObj = new Map<String, Object>();
    reqObj.put('version', '1.0');
    reqObj.put('action', 'createContact');
    reqObj.put('requestJSON', reqJSON);

//  Placing a request to Breadwinner Global API
Map<String, Object> resp = breadwinner_ns.BreadwinnerNetSuiteAPI.call(reqObj);


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