Suitescript 2.0 - 如何将自定义工作流程字段放入脚本中
Suitescript 2.0 - How to get custom workflow fields into script
我创建了一个工作流,其中包含一个工作流操作脚本,用于使用批量更新创建新记录。
这是有效的,但现在我需要将在批量更新屏幕中设置的自定义工作流字段的值传递到脚本中,因此我使用它们来设置新记录的值,但我无法弄清楚。
如有任何帮助,我们将不胜感激。
谢谢
在脚本中创建参数,然后在工作流中调用自定义操作脚本时,将工作流字段值传递给脚本参数。
如果您创建了自定义批量更新脚本,您将创建访问参数,如:
runtime.getCurrentScript().getParameter({name:'custscript....'});
如果是这样,您将通过以下方式触发工作流程:
workflow.initiate({
recordType:'customer', ...
那么你可能会这样做:
/**
* @NApiVersion 2.x
* @NScriptType MassUpdateScript
*/
define(["N/runtime", "N/workflow"], function (runtime, workflow) {
function each(params) {
workflow.initiate({
workflowId:'customworkflow_target_id'
recordType: params.type,
recordId: params.id
defaultValues:{
custworkflow_field_1:runtime.getCurrentScript().getParameter({name:'custscript_field_1'})
// and so on. of course you'll probably dereference runtime.getCurrentScript() if you have multiple parameters
// You'll have to define workflow fields for every value you want to pass.
// custscript_field_1 is from the id of the workflow fields.
// For sanity's sake I recommend giving your script parameters similar ids as the workflow field ids
}
});
}
exports.each = each;
});
我创建了一个工作流,其中包含一个工作流操作脚本,用于使用批量更新创建新记录。
这是有效的,但现在我需要将在批量更新屏幕中设置的自定义工作流字段的值传递到脚本中,因此我使用它们来设置新记录的值,但我无法弄清楚。
如有任何帮助,我们将不胜感激。
谢谢
在脚本中创建参数,然后在工作流中调用自定义操作脚本时,将工作流字段值传递给脚本参数。
如果您创建了自定义批量更新脚本,您将创建访问参数,如:
runtime.getCurrentScript().getParameter({name:'custscript....'});
如果是这样,您将通过以下方式触发工作流程:
workflow.initiate({
recordType:'customer', ...
那么你可能会这样做:
/**
* @NApiVersion 2.x
* @NScriptType MassUpdateScript
*/
define(["N/runtime", "N/workflow"], function (runtime, workflow) {
function each(params) {
workflow.initiate({
workflowId:'customworkflow_target_id'
recordType: params.type,
recordId: params.id
defaultValues:{
custworkflow_field_1:runtime.getCurrentScript().getParameter({name:'custscript_field_1'})
// and so on. of course you'll probably dereference runtime.getCurrentScript() if you have multiple parameters
// You'll have to define workflow fields for every value you want to pass.
// custscript_field_1 is from the id of the workflow fields.
// For sanity's sake I recommend giving your script parameters similar ids as the workflow field ids
}
});
}
exports.each = each;
});