首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从客户端脚本servicenow调用脚本include?

如何从客户端脚本servicenow调用脚本include?
EN

Stack Overflow用户
提问于 2021-04-30 13:42:16
回答 1查看 1K关注 0票数 0

谁能帮助我如何从客户端脚本调用脚本包含?

代码语言:javascript
运行
复制
function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue === '') {
        return;
    }

    //Current assignment group
    var assignment_group = newValue;
    if(assignment_group){
        var coe = '';
        var ga = new GlideAjax('sn_hr_core.scriptIncludeNameUtils'); //Script include
        ga.addParam('sysparm_name','MethodName'); //Method/Function
        ga.addParam('assignment_group',assignment_group); //Parameter
        ga.getXMLAnswer(function(response){
            coe = response;
            if(coe){
                g_form.setValue('u_hr_coe', coe);
            }
        });
    }
}

脚本包括:

代码语言:javascript
运行
复制
MethodName: function (assignment_group) {
    var sys_id = this.getParameter('assignment_group') ? this.getParameter('assignment_group') : assignment_group; //Params
    var result = '';
    if(sys_id){
        var grSysChoice = new GlideRecord('sys_choice');
        grSysChoice.addEncodedQuery("element=assignment_group^name=sn_hr_core_case^dependent_value="+sys_id);
        grSysChoice.orderBy('sequence');
        grSysChoice.setLimit(1);
        grSysChoice.query();
        if(grSysChoice.next()) {
            result = grSysChoice.getValue('value');
        }
    }
    return result;
},
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-30 13:42:16

我们需要使用GlideAjax从客户端脚本中调用脚本include。

代码语言:javascript
运行
复制
var ga = new GlideAjax('sn_hr_core.scriptIncludeNameUtils'); //Script include
ga.addParam('sysparm_name','MethodName'); //Method/Function
ga.addParam('assignment_group',assignment_group); //Parameter
ga.getXMLAnswer(function(response){
    coe = response;
    if(coe){
        g_form.setValue('u_hr_coe', coe);
    }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67328749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档