Jeniffer
05/22/2025, 9:06 PMCeligo AI
05/22/2025, 9:07 PMAI generated answer (using internal Slack threads):To set the linked order on a Purchase Order line item with N/record module to a Requisition record, you can use the
setCurrentSublistValue
method. Here is a sample code snippet that demonstrates how to do this:
javascript
require(['N/record', 'N/currentRecord'], (record, currentRecord) => {
let req = record.load({type: record.Type.PURCHASE_REQUISITION, id: '11716520'})
console.log(req.getValue({fieldId: 'tranid'}))
let cr = currentRecord.get()
let reqLc = req.getLineCount({sublistId: 'item'})
for (let i = 0; i < reqLc; i++) {
let reqItem = req.getSublistValue({sublistId: 'item', fieldId: 'item', line: i})
let reqQty = req.getSublistValue({sublistId: 'item', fieldId: 'quantity', line: i})
cr.selectNewLine({sublistId: 'item'})
cr.setCurrentSublistValue({sublistId: 'item', fieldId: 'item', value: reqItem})
cr.setCurrentSublistValue({sublistId: 'item', fieldId: 'quantity', value: reqQty})
cr.commitLine({sublistId: 'item'})
}
})
This script loads a Purchase Requisition record, gets the line count of the 'item' sublist, and then loops through each line. For each line, it gets the item and quantity values, selects a new line on the current record (which should be a Purchase Order), sets the item and quantity values, and then commits the line.
Please note that setCurrentSublistValue
is asynchronous, so you might need to use forceSyncSourcing
to make it synchronous if you encounter any issues.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
05/22/2025, 9:07 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.8071208
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806143582
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.806072474
Celigo AI
05/22/2025, 9:07 PMCeligo AI
05/22/2025, 9:11 PM