Suitescript Code for getting customer ID from Itemfulfilment Record

Using SUitescript 2.0 function search.lookupFields we can get any fields in sales order, from there we can get customer id for the correspomding customer record.

Code snippet:
var amount_vlaues = search.lookupFields({
    type: search.Type.SALES_ORDER,
    id: salerorderID,
    columns: ["entity"]
});

var customerID = amount_vlaues.entity;
//the value getting from entity is object having both id and value of customer record from that we can split the id only.
var customerData = customerID[0].value
var custIDvalue = (customerData).split(' ')[0];

var custRecord = record.load({
    type: 'customer',
    id: custIDvalue,
    isDynamic: true,
});
//this way we can load a customer record

Leave a comment

Your email address will not be published. Required fields are marked *