Script Include does not change field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 06:09 AM
Hi,
I have the field u_record_changed on incident table. I have a Business Rule that should change the value of the field u_record_change to True on Update.
I have this Script Include: (Even though Im getting the logs Alon1 and Alon2, the field value stay on True but it should be False) Does anyone know why?
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-01-2023 10:46 PM
Hi @Alon Grod ,
It seems there's no exception in executing the update. I suspect there might be something else which is changing the value back to true. You can track the field value changes by using Activity filter. In the notes section add the field u_record_changed to the activity, then try again. You may get some lead.
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2023 08:04 AM