I have a strange one. I'm adding credit card info ...
# suitescript
s
I have a strange one. I'm adding credit card info to a customer. When I commit the sublist, no problem, when I save the record I'm getting Error Saving Customer null my code is try { mycustomer.save({enableSourcing: false,ignoreMandatoryFields: true}); } catch(e) { log.debug('','Error Saving Customer ' + e.message); } Any idea why the e.message is null ? Unfortunately the customer is not saved
b
just throw the error to see what it is
s
log.debug('','Error Saving Customer ' + e.message);
e.message show the error ?
b
things that are thrown are not required to have a message property
you could throw a string if you want
s
I always use e.message but if there's something else I would like to know. Thanks
e
log.debug('Error Saving Customer', e) to see the whole error
s
I didn't know that. Let me try. Thanks
{ type: "error.SuiteScriptError", name: "UNEXPECTED_ERROR", message: null, stack: [ "anonymous(N/serverRecordService)", "onRequest(/SuiteScripts/CopyCustomer.js:181)" ], cause: { type: "internal error", code: "UNEXPECTED_ERROR", details: null, userEvent: null, stackTrace: [ "anonymous(N/serverRecordService)", "onRequest(/SuiteScripts/CopyCustomer.js:181)" ], notifyOff: false }, id: "8b50fcfb-eeff-4814-8f57-2725049f992-99991392e31312e3230", notifyOff: false, userFacing: false }
And what is on 181 is
mycustomer.save({enableSourcing: false,ignoreMandatoryFields: true});
I tried enableSourcing: true
I change ignor... who know
b
you can try sharing more code, but in general unexpected error is netsuite's way of saying something went wrong
you can try netsuite support to see if they will give you more details
s
thanks
e
Are you adding credit card info to the creditcards sublist?
s
That's what I'm trying to do ?
e
so seven fields and you're loading the customer record before you add the cc info?
s
this is the script
var mycustomer = record.load({idvcust1,type record.Type.CUSTOMER,isDynamic: true}); mycustomer.selectNewLine({sublistId : 'creditcards',}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccname',value : ttccname}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccexpiredate',value : ttccexpiredate}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccnumber',value : ttccnumber}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'paymentmethod',value : ttpaymentmethod}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'customercode',value : ttcustomercode}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccexpiredate',value : ttccexpiredate}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'cardstate',value : ttcardstate}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'debitcardissueno',value : ttdebitcardissueno}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccdefault',value : ttccdefault}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ccpanid',value : ttccpanid}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'ispaymentcardtoken',value : ttispaymentcardtoken}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'statefrom',value : ttstatefrom}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'sys_id',value : ttsys_id}); mycustomer.setCurrentSublistValue({sublistId : 'creditcards',fieldId : 'sys_parentid',value : ttsys_parentid}); try { mycustomer.commitLine({sublistId:"creditcards"}); log.debug('','No problem committing line'); } catch(e) { log.debug('','Error Committing Line ' + e.message); } try { var vrecid = mycustomer.save({enableSourcing: true,ignoreMandatoryFields: false}); } catch(e) { log.debug('','Error Saving Customer ' + e);
b
in general, i would tell you to think very carefully about pci complicance when doing credit card stuff
and not to set fields that you can't set in the ui
s
good point
e
Those were the only fields I had to set and it worked for me before.