```customerRec.setCurrentSublistValue({ ...
# suitescript
d
Copy code
customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'cardstate',
          value: "4"
        });
n
which record?
d
Customer record
@NElliott
n
have you selected the line you want to change before hand?
you probably need to post more of your code. Sorry I've become very busy but will try and check back later to see if I can help.
d
Copy code
customerRec.insertLine({
          sublistId: 'creditcards',
          line: 0
        });
        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'ccnumber',
          value: options.params.ccNumber.replace(/\s+/g, '')
        });
        log.debug("Customer sublist fields ", customerRec.getSublistFields({ sublistId: 'creditcards' }));


        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'paymentmethod',
          value: options.params.cardtypenum
        });

        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'cardState',
          value: "4"
        });
        log.debug("cc exp month/year", (options.params.expDate1 + '/' + options.params.expDate2));

        var ccExpireDate = format.parse({ type: format.Type.MMYYDATE, value: (options.params.expDate1 + '/' + options.params.expDate2) });
        log.debug("cc exp date", ccExpireDate);
        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'ccexpiredate',
          value: ccExpireDate
        });
        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'ccname',
          value: options.params.nameoncc
        });
        customerRec.setCurrentSublistValue({
          sublistId: 'creditcards',
          fieldId: 'ccdefault',
          value: true
        });
        customerRec.commitLine({
          sublistId: 'creditcards'
        });
        log.debug("params", options.params);
        customerRec.selectNewLine({
          sublistId: 'addressbook'
        });
        var addressSubrecord = customerRec.getCurrentSublistSubrecord({
          sublistId: 'addressbook',
          fieldId: 'addressbookaddress'
        });
        addressSubrecord.setValue({
          fieldId: 'country',
          value: options.params.country
        });

        addressSubrecord.setValue({
          fieldId: 'state',
          value: options.params.state
        });
        addressSubrecord.setValue({
          fieldId: 'zip',
          value: options.params.zip
        });
        addressSubrecord.setValue({
          fieldId: 'addr1',
          value: options.params.billingAddress
        });
        customerRec.commitLine({
          sublistId: 'addressbook'
        });
        return customerRec.save();
      }
@NElliott
s
Are you trying to enter value in a custom sublist?
d
May be it was setup by a another developer but cardstate is in the default NS sublist.
k
You will be unable to modify this list due to PCI Compliance.
I have tried many timse but fail everytime.
d
ok
Waiting for @NElliott answer if any.
s
if it is a custom sublist it is created by making a parent child relationship between the 2 records. So if you are trying to enter data into the sublist the sublist ID would be very different than what you have written. sublist id in that case would be something like 'recmachcustrecord_interview_parent' which is the internal id of the field that is a list of the parent record along with recmach in front of it.
I hope I was able to explain a little. 😅
n
The sublist is a "standard" Netsuite list except that as has already been pointed out by @karlenigma you're unable to work with it in script. If you ever want to confirm the record format / sublists / searchable columns etc refer to the latest record browser: https://system.eu1.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2019_2/script/record/account.html Apart from that fly in the ointment as far as I can tell the code looks like it should work. If you're looking to work with the cardstate outside of the normal process you may need to introduce a custom field and process to maintain that field to reflect the functionality you require.
✔️ 1