Hey all! I’m struggling to retrieve the value of a...
# suitescript
f
Hey all! I’m struggling to retrieve the value of a custom field from a subrecord.
Copy code
const custRec = record.load({
            type: record.Type.CUSTOMER,
        id: customer,
        isDynamic: true
        })

        const addressLines = custRec.getLineCount('addressbook')
        let freightAccountNo
        for (let i = 0; i < addressLines; i++) {
            const shipLabel = custRec.getSublistText({ sublistId: 'addressbook', fieldId: 'label', line: i })
            if (shipLabel === shipTo) {
                const addressSubrecord = custRec.getCurrentSublistSubrecord({ sublistId: 'addressbook', fieldId: 'addressbookaddress' })

                freightAccountNo = addressSubrecord.getText({
                    fieldId: 'custrecord_cb_freight_account_no'
                })
            }
        }
If I change the field id from ‘custrecord_cb_freight_account_no’ to ‘country’ I do get back what I expect. However, ‘custrecord_cb_freight_account_no’ returns nothing. Has anyone worked with subrecords before? How can I retrieve the value below? (see pictures)
s
Does that field have a Text value? Try addressSubrecord.getValue
f
Sorry, should’ve said in the post that I have tried that. Same result
Needed to do a selectLine, solved it! 😀
s
ugh, maybe avoid dynamic mode if you can
and FWIW, with NFT accessing that is just something like
customer.addressbook[0].addressbookaddress.custrecord_cb_freight_account_no