【问题标题】:Undefined when trying to change a field. ServiceNow尝试更改字段时未定义。立即服务
【发布时间】:2016-03-03 15:37:45
【问题描述】:

我正在处理三个字段:呼叫者、受影响的用户和办公室位置。只是构建这个小脚本来扩展。如果你不知道的话,这里是新手。我们的组织现在刚刚开始服务。刚刚完成管理员培训。

当调用者更改时,它也会使用用户名填充“受影响的用户”字段。 (我们有很多人为其他人制造事件。)

效果很好。但是,当它更改受用户影响时,Office 位置应该填充该位置,但它只填充“未定义”

但是当我自己更改“受影响的用户”字段时,它可以正常工作。

我的脚本改变了一些东西和我改变了一些东西之间有区别吗?这是脚本。

function onChange(control, oldValue, newValue, isLoading) { if (isLoading) return;

if (newValue == '') { g_form.setValue('u_office_location', ''); return; }

if (!g_form.getControl('u_office_location')) return;

var u_user_affected = g_form.getReference('u_user_affected', setLocation); }

function setLocation(u_user_affected) { if (u_user_affected) g_form.setValue('u_office_location', u_user_affected.u_office_location); }

这是从调用者填充用户影响的脚本

function onChange(control, oldValue, newValue, isLoading) { if (isLoading) return;

if (newValue == '') { g_form.setValue('u_user_affected', ''); return; }

if (!g_form.getControl('u_user_affected')) return;

var caller = g_form.getReference('caller_id', setLocation); }

function setLocation(caller) { if (caller) g_form.setValue('u_user_affected', caller.name); }

【问题讨论】:

  • 我不知道你的问题的答案,但我知道你很可能会在这里得到更快的回复:community.servicenow.com/welcome
  • 谢谢你我会继续。我们是新来这里服务的,所以试图了解他们的资源是如何工作的。

标签: servicenow


【解决方案1】:

我用 caller.name 填充该字段,这只是文本。我没有填充参考

以下是填充受呼叫者影响的用户的脚本的修复程序。

function onChange(control, oldValue, newValue, isLoading) {   
    var id = g_form.getValue('caller_id');//replace 'u_first_field' with the name of your reference field.   
    if (g_form.getValue('u_user_affected') == ""){ 
        g_form.setValue('u_user_affected', id);   
    } 

}  

【讨论】:

    猜你喜欢
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多