4N335
4N335

Reputation: 281

how to get the 'Credit Applied' sublist data in Vendor Payment Record from script? (NetSuite)

i need to reflect the credit applied sublist data in my printout suitelet enter image description here

but when i get the line count for credit line( var itemCount_credit = billPayRec.getLineCount({ 'sublistId': 'credit' }); ), system logs line count as -1. Is there any way to fetch this data and if its possible from search than any suggestion what filters / columns woul i require to include?

Upvotes: 0

Views: 1253

Answers (2)

bknights
bknights

Reputation: 15367

Since you are using a Suitelet you can extract the credits applied as follows. This was run in the console but the core of it would work in a SS2.1 script. Convert ()=>{ functions to function(){ for SS2.0

require(['N/search'], search=>{
    const appys = [];
    search.create({
        type:'vendorbill',
        filters: [
            [ 'internalid', 'is', 'your vendor bill internalid']
        ],
        columns:[
            'tranid',
            'applyinglinkamount',
            'applyinglinktype',
            'applyingtransaction'
        ]
    }).run().each(ref=>{
        if(ref.getValue({name:'applyingtransaction'})) appys.push(ref.getValue({name:'applyingtransaction'}));
        const c = ref.columns;
        c.forEach(c=>{
            const v = ref.getValue(c);
            if(!v) return;
            console.log(c.name, v);
        });
        console.log('');
        return true;
    });

    search.create({
        type:'transaction', // or just vendorcredit for you original question
        filters:[
            ['internalid', 'anyof', appys], 'AND',
            ['mainline', 'is', 'T']
        ],
        columns:['tranid'] // plus any columns of interest. 
    }).run().each(ref=>{
        // if filtering type:'transaction' you'll get a mix of vendorcredit, vendorpayment, journalentry
        console.log(ref.recordType, ref.getValue({name:'tranid'})); 
        return true;
    });
});

Upvotes: 0

GimmeDatPP
GimmeDatPP

Reputation: 71

Unless you are able to intercept the request, no. They keep this information obfuscated and by the time it has reached the sublist, it's just cached data. You could get some of the field data with inspect element but likely only what you can see.

Upvotes: 2

Related Questions