场景
当客户回复案例电子邮件(CASE)时,NetSuite会创建一个新的Message记录,并引用该案例,但不会对该案例记录进行任何更改,因此,不会触发部署到该案例记录的用户事件脚本和工作流。
方案
以下步骤显示了如何创建用户事件脚本并将其部署到Messages中,以在客户通过电子邮件更新案例时将案例的状态更改为“重新打开”:
function afterSubmit(type)
{
// Load the message record
var message = nlapiGetNewRecord();
// Get the ID of the activity associated with the message
var activity = message.getFieldValue('activity');
// If there is any activityif(activity)
{
// If the activity is a case, load the record and change the status.try
{
var caseRecord = nlapiLoadRecord('supportcase', activity);
caseRecord.setFieldValue('status',4);
nlapiSubmitRecord(caseRecord);
}
// If the activity is not a Case, log a warning messagecatch(exec)
{
nlapiLogExecution('DEBUG', 'Warning','Activity Record is not a Case');
}
}
}
-部署脚本
1. Go to Customization > Scripting > Scripts > New.
2. Select User Event.
3. In the Name field, enter UE Message.
4. Under the Scripts tab:
In the Script File field, select the JavaScript file created before.
In the After Submit Function field, enter afterSubmit
5. Under the Deployments tab, create a new deployment:
Applied To = Message
Deployed = Yes
Status = Released
Log Level = Debug
网友评论