Client Script not triggering for itil users

James Michaels1
Giga Expert

I have a client script below that should trigger on load of an incident and if the locked field is checked do some alerts. It seems to work just fine for admins but doesn't trigger at all for itil users. I saw a somewhat related problem that was tied to ACLs but other than the incident table I can't think where I might need an acl. Any suggestions are appreciated.

function onLoad() {
         alert('start')
         var ticket = g_form.getUniqueValue();
         var incidents = new GlideRecord('incident');
         alert('start query')
         incidents.addQuery('sys_id', ticket)
         incidents.query();
         alert('run query')
         while (incidents.next()) {
                   var user = g_user.getUserName();
                   if (incidents.u_lock_ticket) {                             
                             if (user == incidents.u_locked_by) {
                                       alert('You have this ticket locked')
                             }
                             else if (g_user.hasRole('admin')) {
                                       alert('User ' + incidents.u_locked_by + ' has this ticket open');
                             }
                             else {
                                       alert('User ' + incidents.u_locked_by + ' has this ticket open. Please confer with that user')
                                       action.setRedirectURL('home.do');
                             }
                   };
         };
};
1 ACCEPTED SOLUTION

will_leingang
ServiceNow Employee
ServiceNow Employee

Hi James. Am I correctly understanding that an itil user doesn't even see the alert('start')?



I would try a few things:



  1. Is this client script view specific? You might need to make it global.
  2. Are you sure your itil user is viewing the same form/table as the admin user? You might need to mark it inherit.
  3. If you open your javascript console in your browser do you see any javascript errors?
  4. Is the client script just set on the incident form? If so, how is the itil user accessing that form?


-Will


View solution in original post

2 REPLIES 2

will_leingang
ServiceNow Employee
ServiceNow Employee

Hi James. Am I correctly understanding that an itil user doesn't even see the alert('start')?



I would try a few things:



  1. Is this client script view specific? You might need to make it global.
  2. Are you sure your itil user is viewing the same form/table as the admin user? You might need to mark it inherit.
  3. If you open your javascript console in your browser do you see any javascript errors?
  4. Is the client script just set on the incident form? If so, how is the itil user accessing that form?


-Will


James Michaels1
Giga Expert

It seems to have been the inherit. After enabling that the itil user triggers the script when opening incidents. Thank you!