Steven Craig
04/29/2026, 2:53 PMCeligo AI
04/29/2026, 2:53 PMAI generated answer (using internal Slack threads):To link a Purchase Order (PO) to an item on a Sales Order (SO) without using a custom field, you can use SuiteScript to automate this process. Here's a general approach: 1. Create a User Event script that triggers on the creation or update of a Sales Order. 2. In the script, identify the item that needs to be linked to a Purchase Order. 3. Search for the corresponding Purchase Order that contains the same item. 4. Once the Purchase Order is found, you can link it to the Sales Order by setting the 'Created From' field on the Purchase Order to the internal ID of the Sales Order. Please note that this approach assumes that the Purchase Order is created after the Sales Order. If the Purchase Order is created before the Sales Order, you might need to adjust the script to run on the creation or update of a Purchase Order instead. Here's a simplified example of what the SuiteScript might look like:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record', 'N/search'], function(record, search) {
function afterSubmit(context) {
var salesOrder = context.newRecord;
var itemId = salesOrder.getValue('item');
var poSearch = search.create({
type: search.Type.PURCHASE_ORDER,
filters: [['item', 'anyof', itemId]]
});
var poSearchResult = poSearch.run().getRange({start: 0, end: 1});
if (poSearchResult.length > 0) {
var po = record.load({
type: record.Type.PURCHASE_ORDER,
id: poSearchResult[0].id
});
po.setValue('createdfrom', salesOrder.id);
po.save();
}
}
return {
afterSubmit: afterSubmit
};
});
This script will run every time a Sales Order is created or updated. It will search for a Purchase Order with the same item and link it to the Sales Order.
******
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
04/29/2026, 2:54 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.85949707
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.855651855
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848632812
Celigo AI
04/29/2026, 2:54 PM