Script Include and OnLoad client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 03:54 AM
Hi,
I have an onLoad client script on incident table that calls Script Include. The script include checks if login user is belong to some group, if he does he need to update the field u_record_changed to False. On the other hand, I need to write a BR on the incident table that every time a user make an update, the BR need to set u_record_changed to True.
The problem is that in my script include im using 'inc.update()' in order to set the field to false and then because its an update the BR override the Script Include and set the field to True again, even though the goal is that it should stay on False. Any users that make update, the field should be set to True. If the login user belong to special group and he just load the incident without making any update then the field should be set to False.
var SetRecordChangedFalse = Class.create();
SetRecordChangedFalse.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isHamal: function() {
var std = this.getParameter('sysparm_std');
var num = this.getParameter('sysparm_num');
var standardFields = new GlideRecord('sys_user_grmember');
standardFields.addQuery('user', std);
standardFields.query();
while (standardFields.next()) {
var group_name = standardFields.group.toString();
var gr = new GlideRecord('sys_user_group');
gr.addEncodedQuery('sys_id=' + group_name + '^u_hamal=true');
gr.query();
if (gr.next()) {
gs.log('ALon1');
var inc = new GlideRecord('incident');
inc.addEncodedQuery('sys_id=' + num);
inc.query();
if (inc.next()) {
gs.log('Alon2');
inc.setValue('u_record_changed', false);
inc.update();
}
}
}
},
type: 'SetRecordChangedFalse'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2023 05:07 AM
