Create Contact
Sample Requests and Responses
The following is an example request which can be used while using ‘createContact’ action.
Request
// 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);
System.debug(resp);
Response
{
action=createContact,
timestamp=1607423183079,
validRequest=true,
version=1.0,
responseJSON={
"status": "200"
"errors": [],
"contacts": [
{
"title": "CEO",
"subsidiary": {
"type": null,
"name": "Parent Company",
"internalId": "1",
"externalId": null
},
"salutation": null,
"salesforceID": "a022w00000IXl0bAAD",
"publicSubscriptionStatus": null,
"phone": "3453254543",
"officePhone": "6546564564",
"nullFieldList": null,
"mobilePhone": null,
"middleName": null,
"lastName": "Williams",
"lastModifiedDate": 1607423181,
"isPrivate": true,
"isInactive": false,
"internalId": "32542",
"homePhone": null,
"firstName": "James",
"fax": null,
"externalId": null,
"entityId": "James Williams",
"email": "james@grandhotel.com",
"defaultAddress": "James Williams\nSuite 201\n2334 Park Street Avenue\nChicago IL 60601\nUnited States",
"dateCreated": 1607423180,
"customForm": null,
"customFieldList": {
"customField": [
{
"valueLookup": null,
"value": "true",
"scriptId": "custentity_f3_mm_send_wf_sms",
"internalId": "428",
"fieldType": null
},
{
"valueLookup": null,
"value": "james12@gmail.com",
"scriptId": "custentity_alt1_email",
"internalId": "485",
"fieldType": null
}
]
},
"company": {
"type": null,
"name": "CUST533AT Grand Hotels & Resorts Ltd",
"internalId": "32342",
"externalId": null
},
"comments": null,
"assistant": null,
"altEmail": null,
"addressbookList": {
"replaceAll": null,
"addressbook": [
{
"label": "Suite 201",
"isResidential": null,
"internalId": "29889",
"defaultShipping": true,
"defaultBilling": true,
"addressbookAddress": {
"zip": "60601",
"state": "IL",
"internalId": null,
"country": "_unitedStates",
"city": "Chicago",
"attention": null,
"addrPhone": null,
"addressee": "James Williams",
"addr3": null,
"addr2": "2334 Park Street Avenue",
"addr1": "Suite 201"
}
}
]
}
}
]
}
}