Global API
...
Requests
Credit Memo
Update
1min
the following is an example of updating a credit memo where we are changing some of the fields (see credit memo docid\ rogvpwavijlodmlujjwd5 for all available fields) the netsuite credit memo id (internalid) is required to update the credit memo note you can only update one record at a time the response returns the complete credit memo information, but we have shortened the response in our example for ease of reading request // create a map to store all the data of a cm map\<string, object> nscm = new map\<string, object>(); nscm put('internalid', '121563'); nscm put('classification', new map\<string, object>{'internalid'=>'4'}); nscm put('department', new map\<string, object>{'internalid'=>'3'}); 	nscm put('location', new map\<string, object>{'internalid'=>'10'}); nscm put('discountitem', new map\<string, object>{'internalid'=>' 6'}); nscm put('discountrate', ' 20'); nscm put('entity', new map\<string, object>{'internalid'=>'362'}); nscm put('memo', 'order 300'); nscm put('otherrefnum', '4343390'); nscm put('trandate', datetime newinstance(2023, 09, 07) gettime()/1000); // apply only to approved status containing invoices and having same customer as credit memo list\<object> creditmemoapplylist = new list\<object>(); map\<string,object> apply = new map\<string,object>(); apply put('doc', '131747'); apply put('line', '0'); apply put('apply',true); creditmemoapplylist add(apply); nscm put('applylist', new map\<string,object>{'apply'=>creditmemoapplylist,'replaceall'=>false}); // 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'=>'3'}); 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 test'); lineitem put('item', new map\<string, object>{'internalid'=>'2917'}); lineitem put('replaceall', false); lineitem put('amount', 10); lineitem put('quantity', 2); lineitem put('grossamt', 220); lineitem put('tax1amt', 210); lineitem put('revrecenddate', datetime newinstance(2023, 09, 07) gettime()/1000); lineitem put('revrecstartdate', datetime newinstance(2024, 09, 07) gettime()/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', 'custbody checkbox'); licustomfield put('value', 'false'); 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', 'updatecreditmemo'); 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=updatecreditmemo, timestamp= 1682506549179, validrequest=true, version=1 0, responsejson={ "status" "200", "errors" \[], "creditmemos" \[ { "tranid" "170", "trandate" 1694055600, "total" 200 0, "taxtotal" 0 0, "subtotal" 220 0, "subsidiary" { "type" null, "name" "parent company", "internalid" "1", "externalid" null }, "status" "open", "shippingcost" null, "salesrep" null, "salesforceid" "a061e000003uzjyaak", "refundcheck" null, "otherrefnum" "4343390", "memo" "order 300", "location" { "type" null, "name" "hyderabad hi tech city", "internalid" "10", "externalid" null }, "lastmodifieddate" 1682506545, "job" null, "itemlist" { "replaceall" null, "item" \[ { "unitsdisplay" null, "taxrate1" "0 0", "taxcode" { "type" null, "name" "vat in\ no tax", "internalid" "20", "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" 2 0, "price" { "type" null, "name" null, "internalid" " 1", "externalid" null }, "ponum" null, "percentcomplete" null, "orderline" null, "onhand" null, "location" null, "line" 6, "jobname" null, "itemreceive" null, "itemname" null, "itemisfulfilled" null, "item" { "type" null, "name" "fastrack watch", "internalid" "2917", "externalid" null }, "isclosed" null, "grossamt" 220 0, "expectedreceiptdate" null, "description" "a weapon for shooting arrows test", "department" null, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "false", "scriptid" "custcol checkbox", "internalid" "443", "fieldtype" null } ] }, "createpo" null, "costestimatetype" " lastpurchaseprice", "costestimate" 0 0, "classification" null, "billingschedule" null, "amount" 220 0 } ] }, "internalid" "121563", "handlingcost" 0 0, "externalid" null, "exchangerate" 23 0, "entity" { "type" null, "name" "21 atherton grocery", "internalid" "362", "externalid" null }, "discounttotal" 20 0, "discountrate" " 20 00", "discountitem" { "type" null, "name" "partner discount", "internalid" " 6", "externalid" null }, "department" { "type" null, "name" "test", "internalid" "3", "externalid" null }, "customform" { "type" null, "name" "custom credit memo 2", "internalid" "114", "externalid" null }, "customfieldlist" { "customfield" \[ { "valuelookup" null, "value" "200", "scriptid" "custbody42", "internalid" "869", "fieldtype" null }, { "valuelookup" null, "value" " ", "scriptid" "custbody breadwinner pc internal id", "internalid" "588", "fieldtype" null }, { "valuelookup" { "type" null, "name" "c", "internalid" "3", "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" "us dollars", "internalid" "2", "externalid" null }, "currencyname" "us dollars", "createdfrom" null, "createddate" 1682505153, "classification" { "type" null, "name" "pc", "internalid" "4", "externalid" null }, "applylist" { "apply" \[ { "type" "invoice", "total" 7027 14, "refnum" "inv583", "line" "0", "due" 7027 14, "doc" "131747", "currencyvalue" "inr", "applydate" 1689231600, "apply" true, "amount" 7027 14 } ] }, "applied" 7027 14, "account" { "type" null, "name" "accounts receivable", "internalid" "122", "externalid" null } } ] } }