bluejay92
bluejay92

Reputation: 161

Suitescript - How do I access "Related Records" subtab and get/store their associated values?

I am trying to get the associated values from the related records subtab. For example, I am trying to get the associated bills values (amount billed) on a purchase order. There is no other way to do what I am trying to do besides getting those values OR I need to get the "amount billed" or "amount unbilled" column field on the items subtab per each item. I can find the internal id of "amount unbilled" as 'amountunbilled' but trying to retrieve the value of this column on a line gives me null. (Also, there is no "Amount Unbilled" column but there is a "Billed" column that is disabled as it is a calculation I am assuming - I cannot access this column to get this value).


UPDATE:

So I actually found that "Amount Unbilled" is accessible while I am on a different record. However I would still love to know how I could access items on the Related Records subtab.

Upvotes: 2

Views: 6307

Answers (2)

earj
earj

Reputation: 76

You can retrieve the internal id of the bill associated to the purchase order using this:

var vendorBillId = nlapiGetLineItemValue("links", "id", 1);

Then load the vendor bill using the retrieved id and get the amount.

Upvotes: 1

bknights
bknights

Reputation: 15402

generally you do that with a transaction search using a filter for created from:

nlapiSearchRecord('transaction', null, 
 [
   new nlobjSearchFilter('createdfrom', null, 'is', nlapiGetRecordId()),
   new nlobjSearchFilter('mainline', null, 'is', 'T'),
  ...

The list of fields available for search filters or search results is available at https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/script/record/transaction.html

Or if you are focused on bills attached to POs:

var bills = nlapiSearchRecord('vendorbill', null, [
        new nlobjSearchFilter('createdfrom', null, 'is', poId),
        new nlobjSearchFilter('mainline', null, 'is', 'T')
]);

Upvotes: 3

Related Questions