将 sys_id 显示值分配给 servicenow 中的字符串字段

问题描述 投票:0回答:1

我正在尝试在名为“创建事件”的反馈表单上创建一个按钮。 一旦用户单击按钮,则应创建缩进,并且应将创建的事件的编号填充到反馈表单(在现有记录上)的字符串字段中。

here code snippet

servicenow
1个回答
0
投票

我认为客户端 UI 操作和客户端可调用脚本是您需要满足的要求。在我为您创建的示例中: ui action configuration

this is script include which returns server side info

这是 ui 操作脚本:

function onClick() {
    var ga = new GlideAjax('getIncidentInfo'); // getIncidentInfo is the script include name 
    ga.addParam('sysparm_name', 'createNewIncident'); // createNewIncident is the function in the script include that we're calling 
    ga.addParam('sysparm_assigned_to', g_form.getValue('assigned_to')); // set field as example
    /* Call getIncidentInfo.createNewIncident() with "assigned to" set to g_form.assigned_to  and use the callback function ManagerParse() to return the result when ready */
    ga.getXMLAnswer(populateIncident);

}
// callback function for returning the result from the script include
function populateIncident(response) {
    g_form.setValue('u_related_incident', response)
    g_form.save();
}

这是脚本包括:

var getIncidentInfo = Class.create();
getIncidentInfo.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    createNewIncident: function() {
        var gr = new GlideRecord('incident');
        gr.initialize();
        gr.setValue('assigned_to', this.getParameter("sysparm_assigned_to"));
        gr.insert();
        var uid = gr.getUniqueValue()
        var result = uid;
        return result;
    },
    type: 'getIncidentInfo'
});

要了解有关 GlideAjax 用法的更多信息,请参阅本教程:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/washingtondc/servicenow_application_developer/app_store_learnv2_scripting_washingtondc_extending_glideajax

欲了解更多信息,请查看此处: https://developer.servicenow.com/dev.do#!/reference/api/vancouver/client/c_GlideAjaxAPI

© www.soinside.com 2019 - 2024. All rights reserved.