dennysutanto
09/11/2024, 6:54 AMCeligo AI
09/11/2024, 6:54 AMAI generated answer (using internal Slack threads):To create a task from a sales order using SuiteScript, you would need to write a User Event Script that triggers after the Sales Order record is created or updated. Here is a basic example of how you might do this:
javascript
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
*/
define(['N/record'], function(record) {
function afterSubmit(context) {
if (context.type !== context.UserEventType.CREATE && context.type !== context.UserEventType.EDIT) {
return;
}
var salesOrder = context.newRecord;
var salesOrderId = salesOrder.id;
var task = record.create({
type: record.Type.TASK,
isDynamic: true,
});
task.setValue({
fieldId: 'title',
value: 'Task for Sales Order ' + salesOrderId,
});
task.setValue({
fieldId: 'transaction',
value: salesOrderId,
});
task.save();
}
return {
afterSubmit: afterSubmit,
};
});
In this script, we're creating a new task record and setting the title and transaction fields. The transaction field is a reference to the sales order that triggered the creation of the task.
******
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
09/11/2024, 6:55 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819993794
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817603469
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814951599
Celigo AI
09/11/2024, 6:55 AM