我认为客户端 UI 操作和客户端可调用脚本是您需要满足的要求。在我为您创建的示例中:
这是 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#!/reference/api/vancouver/client/c_GlideAjaxAPI