Boban Dragojlovic
07/18/2025, 6:11 PMCeligo AI
07/18/2025, 6:11 PMAI generated answer (using internal Slack threads):To create a work order from a sales order that is already approved in script, you can use a SuiteScript. Here's a general idea of how you can do it: 1. Create a User Event script that triggers on the 'After Submit' event of the Sales Order record. 2. In the script, check if the Sales Order is approved. You can do this by checking the value of the 'orderstatus' field. If it's 'B', then the Sales Order is approved. 3. If the Sales Order is approved, you can then create a Work Order record. You can do this by using the
record.create
method and setting the necessary fields.
Here's a basic example of how the script might look:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record'], function(record) {
function afterSubmit(context) {
var salesOrder = context.newRecord;
if (salesOrder.getValue('orderstatus') === 'B') { // 'B' is the internal id for Approved status
var workOrder = record.create({
type: record.Type.WORK_ORDER,
// set other necessary fields
});
// set other necessary fields
workOrder.save();
}
}
return {
afterSubmit: afterSubmit
};
});
Please note that this is a simplified example and you might need to adjust it according to your specific needs. For example, you might need to set additional fields on the Work Order record, or you might need to handle errors and edge cases.
******
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
07/18/2025, 6:12 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.849461615
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.837196052
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834483922
Celigo AI
07/18/2025, 6:12 PM