0

我想在 ServiceNow 中添加业务规则。当我使用“To”(直接)或“CC”(复制)将新记录添加到 sys_email 表中时,我想要在插入表之前将“to”或“cc”填充字段复制到“bcc”中的规则提交后提交并删除“to”和“cc”条目。到目前为止,这是我的代码,它不会改变任何东西。我是 ServiceNow 的新手,也许有人可以帮助我?

 (function executeRule(current, previous /*null when async*/) {

var gr = new GlideRecord('sys_email');

//gr.newRecord();

gr.addQuery('direct','current.direct');
gr.addQuery('copied','current.copied');
gr.query();
while(gr.next()) 
{
 gr.blind_copied = current.direct +', '+ current.copied;
 gr.update();
}


  })(current, previous);
4

1 回答 1

0

为此,请确保对表使用before业务规则。您可以在插入之前更改当前记录中的字段。insertupdatesys_email

(function executeRule(current, previous /*null when async*/) {

    // create variables for use from current record
    var to = current.direct;
    var cc = current.copied;
    var bcc += to + '; ' + cc;

    // update the current record
    current.direct = '';
    current.copied = '';
    current.blind_copied = bcc;

})(current, previous);
于 2019-09-10T03:18:02.700 回答