Hey all, did some searching around but didn’t find...
# suitescript
a
Hey all, did some searching around but didn’t find anything specifically relevant to my use-case.. I have a suitelet that parses an excel sheet and creates a sales order from the lines. The suitelet then parses another sheet in the workbook with customer information and CC info and tries to create a Customer Deposit in NS with the card information. had some issues getting the expiry date formatted correct, but I don’t see anything wrong with the hardcoded value below when I copy Paste into NS, it looks like everything is there in terms of fields (not seeing any missing mandatory fields) but for some reason I keep getting an ‘Unexpected SuiteScript Error’ Client is using CyberSource for processing, Sales Orders are coming into NS as Pending Approval, here is a snippet of me setting values on the deposit:
Copy code
try {

            const ccType = getCardType(cardNumber);
            const custDep = record.create({
              type: record.Type.CUSTOMER_DEPOSIT,
              isDynamic: true
            });
            custDep.setValue('customer', customerId);
            custDep.setValue('salesorder', newOrder);
            custDep.setValue('paymentmethod', CARD_TYPE_MAP[ccType]);
            custDep.setValue('ccnumber', cardNumber);
            custDep.setValue('ccexpiredate', '01/2023');
            custDep.setValue('ccsecuritycode', securityCode);
            custDep.setValue('ccstreet', billStreet);
            custDep.setValue('cczipcode', billZip);

            var saveDep = custDep.save({
              ignoreMandatoryFields: true
            });
          } catch (e) {
            log.error('ERROR', e.message);
          }
c
I'd narrow down where the error is actually coming from as your try/catch encompasses several actions. Put a try catch around each piece to narrow it down.
a
Error is being thrown on save
I am even using
N/format
to format a CCEXPDATE date format for the expiration date, per the records browser
s
I'd try changing the setValue to setText for the dates