User Event on Sales Order to get Item record (Sublist) Details.

Script to get Values of Sales Order and load the Item to get sublist value of Item Record.

Use Case: In this example we are going to write a user event script which will be deployed on Sales order and getting the field values of Sales order and line items values of sales order. After storing the item ids in a variable the script is loading the items to get the Item vendor details from the item record.

In this example we are loading a child record and exploring the sublist of child record.

Api Covered : record.load,  getValue for body field, getLineCount for line items, getSublistValue

SALES ORDER =>get ITEM (sublist) => Load ITEM => get ITEM Sublist (Vendor) details

/**

 *@NApiVersion 2.x

 *@NScriptType UserEventScript

 */

define([‘N/record’], function (record) {

function beforeLoad(context) {

}

function beforeSubmit(context) {

var recid = context.oldRecord.id

        log.debug(‘orderid’, recid)

        var SOobj = record.load({

            type: record.Type.SALES_ORDER,

            id: recid,

 })

        //load the SO and get the trandate and store in a variable oderdate

        var oderdate = SOobj.getValue({

            fieldId: ‘trandate’})

log.debug(oderdate);

//get the number of line in SO:  numLines

var numLines = SOobj.getLineCount({

            sublistId: ‘item’

        });

log.debug({

            title: ‘numLines’,

            details: numLines

        })

//loop through the number of line in SO

        for (var i = 0; i < numLines; i++) {

//get the internalid of the item

var internalid_item = SOobj.getSublistValue({

                sublistId: ‘item’,

                fieldId: ‘item’,

                line: i

            });

log.debug({

                title: ‘linedetails’,

                details: ‘line number ‘ + i + ‘is having ‘ + internalid_item

            })

//load the item using the internal id

            var itemObj = record.load({

                type: record.Type.LOT_NUMBERED_INVENTORY_ITEM,

                id: internalid_item,

})

log.debug(‘itemObj’, itemObj)

//check the field dropship item value from item record

            var checkbo = itemObj.getValue({

                fieldId: ‘isdropshipitem’

            })

            if (checkbo) {

                //logic if the dropdhip check box is true we come inside the loop

log.debug(‘insideif’, ‘yes the item is derop ship’) // then get the sublist value of vendor in Item record

var valoue_v =itemObj.getSublistValue({

                    sublistId:’itemvendor’,

                    fieldId:’vendor’ ,

                    line: i     

                    })

                    log.debug({

                        title: ‘valoue_v’,

                        details: valoue_v

                    })

            }

}

    }

    function afterSubmit(context) {

}

    return {

        beforeLoad: beforeLoad,

        beforeSubmit: beforeSubmit,

        afterSubmit: afterSubmit

    }

});

Feel free to reach out Netsuite Solution provider  TheSmilingCoders for proper netsuite implementationnetsuite consultation , netsuite customizationnetsuite Supportnetsuite Training NetSuite Celigo Integration , Celigo ConsultantCeligo Integration Consultant.

contact us : info@smilingcoders.com

Facebook : https://www.facebook.com/Smiling-Coders-Netsuite-Training-Implementation-and-Support-1591053827660082/

Linkedin : https://www.linkedin.com/company/netsuite-academy/


5 Comments

Beatrice

November 25, 2020 at 4:28 pm

Great article! This is the kind of info that are
meant to be shared around the net. Shame on Google for no longer positioning
this submit upper! Come on over and talk over with my web site .
Thanks =)

Here is my blog post; headlamp rechargeable

Colette

November 25, 2020 at 7:59 pm

Hello! Do you know if they make any plugins to help with SEO?

I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success.
If you know of any please share. Cheers!

Here is my site … brightest headlamp

Angie

November 25, 2020 at 11:32 pm

I have to thank you for the efforts you have put in penning
this website. I am hoping to see the same high-grade blog posts from you in the future as well.
In truth, your creative writing abilities has motivated me to get my very own blog now 😉

Here is my webpage … headlamp waterproof

Lottie

November 26, 2020 at 2:35 am

I am truly grateful to the owner of this web site who has shared this impressive article at at this place.

Here is my blog brightest headlamp

Jasper

November 26, 2020 at 5:09 am

Every weekend i used to pay a visit this website, because i want enjoyment,
since this this web page conations in fact pleasant funny
data too.

Visit my homepage headlamp rechargeable

Leave a Reply