Creating a customerdepost record in Suitecript 2.0
I am pulling Payment information from Cybersource using their API’s. I get all the information I need . I am able to create a customerdeposit record without the credit card information. But when I add in the credit card fields I get the error “type”:”error.SuiteScriptError”,”name”:”UNEXPECTED_ERROR”,. The error occurs on the save .
if (totalcharge > 0) { var customerDeposit = record.create({ type: record.Type.CUSTOMER_DEPOSIT, isDynamic: true, defaultValues: { entity: entityId, salesorder: salesOrderId } }); customerDeposit.setValue({ fieldId: 'department', value: 3 }); //get Setup > Company > Departments. customerDeposit.setValue({ fieldId: 'class', value: 26 }); //get Setup > Company > Classes. customerDeposit.setValue({ fieldId: 'payment', value: totalcharge }); customerDeposit.setValue({ fieldId: 'location', value: 16}); customerDeposit.setValue({ fieldId: 'paymentmethod', value: paymethod}); customerDeposit.setValue({ fieldId: 'creditcardprocessor', value: 1}); customerDeposit.setValue({ fieldId: 'trandate', value: new Date() }); customerDeposit.setValue({ fieldId: 'ccapproved', value: true }); customerDeposit.setValue({ fieldId: 'ccname' , value: namecc }); customerDeposit.setValue({ fieldId: 'ccexpiredate', value: ccexpire}); customerDeposit.setValue({ fieldId: 'ccnumber', value: numcc}); customerDeposit.setValue({ fieldId: 'authcode', value: approvalc }); customerDeposit.setValue({ fieldId: 'pnrefnum', value: cstransid }); customerDeposit.setValue({ fieldId: 'currency', value: 1}); var id = customerDeposit.save({ enableSourcing: false, ignoreMandatoryFields: true //note the error occurs regardless if true or false }); log.debug('deposit id', id); return id;
Any insight would be appreciated
Found the answer myself after I slept on it. The value on this line customerDeposit.setValue({ fieldId:
'currency'
, value: 1});
is invalid.