Global API
...
Requests
Credit Memo
Create
1min
to create a credit memo in netsuite, use action as "createcreditmemo" and pass the credit memo data in the requestjson under "creditmemos" note you can only create one record at a time the following is an example of creating a credit memo where we are setting every possible field (see credit memo docid\ rogvpwavijlodmlujjwd5 for the available fields) the response will return the response back from netsuite, which includes credit memo id (internalid), plus the newly created salesforce credit memo id (salesforceid) request // create a map to store all the data of a cm map\<string, object> nscm = new map\<string, object>(); nscm put('classification', new map\<string, object>{'internalid'=>'1'}); nscm put('currencyrecord', new map\<string, object>{'internalid'=>'1'}); nscm put('department', new map\<string, object>{'internalid'=>'1'}); 	nscm put('location', new map\<string, object>{'internalid'=>'10'}); nscm put('discountitem', new map\<string, object>{'internalid'=>' 6'}); nscm put('discountrate', ' 15'); nscm put('entity', new map\<string, object>{'internalid'=>'109118'}); nscm put('memo', 'order 250'); nscm put('otherrefnum', '4343399'); nscm put('trandate', datetime newinstance(2023, 04, 26) gettime()/1000); // initializing the cm custom fields list\<object> cmcustomfieldlist = new list\<object>(); map\<string, object> cmcustomfield = new map\<string, object>(); cmcustomfield put('fieldtype', 'select'); cmcustomfield put('scriptid', 'custbody customlist'); cmcustomfield put('valuelookup', new map\<string, object>{'internalid'=>'2'}); cmcustomfieldlist add(cmcustomfield); // adding the cm custom fields nscm put('customfieldlist', new map\<string, object>{'customfield'=>cmcustomfieldlist}); // initializing the cm 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'=>'9524'}); lineitem put('quantity', 1); 	 lineitem put('amount', 1000); // 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', 'custcol checkbox'); licustomfield put('value', 'true'); licustomfieldlist add(licustomfield); // adding the cm line item custom fields lineitem put('customfieldlist', new map\<string, object>{'customfield'=>licustomfieldlist}); lineitemlist add(lineitem); // adding the line items to cm map\<string, object> cmlineitemlist = new map\<string, object>(); cmlineitemlist put('item', lineitemlist); nscm put('itemlist', cmlineitemlist); // initializing the requestjson data to be passed map\<string, object> requestjsonmap = new map\<string, object>(); requestjsonmap put('creditmemos', new list\<object>{nscm}); string reqjson = json serialize(requestjsonmap); map\<string, object> reqobj = new map\<string, object>(); reqobj put('version', '1 0'); reqobj put('action', 'createcreditmemo'); 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=createcreditmemo, timestamp = 1682505158494, validrequest = true, version = 1 0, responsejson={ "status" "200", "errors" \[], "creditmemos" \[ { "tranid" "170", "trandate" 1682478000, "total" 985 0, "taxtotal" 0 0, "subtotal" 1000 0, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "open", "shippingcost" 0 0, "salesrep" null, "salesforceid" "a061e000003uzjyaak", "refundcheck" null, "otherrefnum" "4343399", "memo" "order 250", "location" { "type" null, "name" "hyderabad hi tech city", "internalid" "10", "externalid" null }, "lastmodifieddate" 1682505153, "job" null, "itemlist" { "replaceall" null, "item" \[ { "unitsdisplay" null, "taxrate1" "0 0", "taxcode" { "type" null, "name" "vat in\ undef in", "internalid" "5", "externalid" null }, "tax1amt" 0 0, "shipmethod" null, "shipgroup" null, "serialnumbers" null, "revrecstartdate" null, "revrecschedule" null, "revrecenddate" null, "rate" null, "quantityremaining" null, "quantityreceived" null, "quantitypicked" null, "quantitypacked" null, "quantityonhand" null, "quantityfulfilled" null, "quantitycommitted" null, "quantitybilled" null, "quantitybackordered" null, "quantityavailable" null, "quantity" 1 0, "price" { "type" null, "name" null, "internalid" " 1", "externalid" null }, "ponum" null, "percentcomplete" null, "orderline" null, "onhand" null, "location" null, "line" 1, "jobname" null, "itemreceive" null, "itemname" null, "itemisfulfilled" null, "item" { "type" null, "name" "electronic oven", "internalid" "9524", "externalid" null }, "isclosed" null, "grossamt" 1000 0, "expectedreceiptdate" null, "description" "a weapon for shooting arrows", "department" null, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "true", "scriptid" "custcol checkbox", "internalid" "443", "fieldtype" null } ] }, "createpo" null, "costestimatetype" " itemdefinedcost", "costestimate" 0 0, "classification" null, "billingschedule" null, "amount" 1000 0 } ] }, "internalid" "121563", "handlingcost" 0 0, "externalid" null, "exchangerate" 1 0, "entity" { "type" null, "name" "cust1402at blue origin", "internalid" "109118", "externalid" null }, "discounttotal" 15 0, "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 credit memo 2", "internalid" "114", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "985", "scriptid" "custbody42", "internalid" "869", "fieldtype" null }, { "valuelookup" null, "value" " ", "scriptid" "custbody breadwinner pc internal id", "internalid" "588", "fieldtype" null }, { "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 }, { "valuelookup" null, "value" "2", "scriptid" "custbody15", "internalid" "182", "fieldtype" null }, { "valuelookup" null, "value" "false", "scriptid" "custbody enableimport", "internalid" "691", "fieldtype" null } ] }, "currencyrecord" { "type" null, "name" "inr", "internalid" "1", "externalid" null }, "currencyname" "inr", "createdfrom" null, "createddate" 1682505153, "classification" { "type" null, "name" "partner class", "internalid" "1", "externalid" null }, "applylist" null, "applied" 0 0, "account" { "type" null, "name" "accounts receivable", "internalid" "122", "externalid" null } } ] } }