- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:19 AM
Hello
I am a junior developer and I have this story with this client script and half include script, I am stuck since it does not execute me correctly and it meets the specifications of the story, I hope you can help me, regards.
As a Process User (itil)
I want that when an incident is submitted, the system checks if the caller is "Joe Employee". If that is the case, an alert must inform that "You cannot submit an incident for Joe Employee" and prohibit incident submission. This should work for new and existing incident
SO THAT Joe Employee is cannot submit incidents
I know this is complete when I cannot have an incident with Joe Employee as the caller.
Portal is not in scope.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 11:03 AM - edited 04-20-2023 11:04 AM
@Tomas Linde Here is your solution
onSubmit Client Script:
function onSubmit() {
var sysId = g_form.getValue('caller_id');
var gaIsJoeEmployee = new GlideAjax('global.IncidentFunction');
gaIsJoeEmployee.addParam('sysparm_name', 'isEmployee');
gaIsJoeEmployee.addParam('sysparm_name_sysid', sysId);
gaIsJoeEmployee.getXMLWait();
var answer = gaIsJoeEmployee.getAnswer();
if (answer == 'true') {
g_form.clearMessages();
g_form.showFieldMsg('caller_id', 'You cannot submit an incident for Joe Employee', 'error');
return false;
} else {
g_form.clearMessages();
}
}
Here is the code for Script Include.
var IncidentFunction = Class.create();
IncidentFunction.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isEmployee: function() {
//var userIsEmployee = this.getParameter('sys_param_name');
var userSysId = this.getParameter('sysparm_name_sysid');
var grName = new GlideRecord('sys_user');
gs.info('I wss here');
grName.addQuery('name', 'Joe Employee');
grName.addQuery('sys_id', userSysId);
grName.query();
var answer = 'false';
if (grName.next()) {
answer = 'true';
}
return answer;
},
type: "IncidentFunction"
});
Here is how the end result looks.
Hope this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:48 AM
@Tomas Linde Could you please post both the scripts here, I will update them and provide a corrected version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 10:14 AM
Hi,
If the requirement is only for the caller 'Joe employee' then you just need one onSubmit client script:
function onSubmit() {
var joeId = '681ccaf9c0a8016400b98a06818d57c7';
if(g_form.getValue('caller_id')==joeId){
alert("You cannot submit an incident for Joe Employee");
return false;
}
}
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 10:19 AM
Thanks for the help, but this story has to be done with a GlideAjax and in a more complex way ,like I do in my captures,
When testing, your version does not meet the criteria.