- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 12:44 AM
Hello,
I have a script action which reacts to an event in a business rule, after this event is triggered I need certain fields to be updated, even if the script action reacts to the event according to log, "current" parameters are accessible within the script according to log, current.update() does not work for some reason...
Script action:
gs.log('!!!MILAN - STORY43....');
setFields();
function setFields() {
current.state = '9';
current.short_description = 'Test from script action';
current.assigned_to = "";
gs.info('!!!MILAN' + current.assigned_to + current.state + current.short_description);
current.update();
}
gs.info in log works with the correct values, however what does not work is the current.update() part as the data on the incident form do not get updated..
Any idea why?
Appreciate your help,
Milan
Log (gs.info('!!!MILAN' + current.assigned_to + current.state + current.short_description);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 01:10 AM
Hello Milan,
try out with below code:
var grIncident = new GlideRecord('incident');
grIncident.addQuery('sys_id',current.sys_id);
grIncident.query();
while(grIncident.next()){
grIncident.short_description = "Test from script action";
grIncident.setValue('assigned_to','');
grIncident.update();
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 12:53 AM
Hi
Why don't you try writing a glide record and then update?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 01:05 AM
I tried below code as well but not working anyway...
gs.log('!!!MILAN - STORY43....');
setFields();
function setFields() {
gs.info('!!!MILAN' + current.assigned_to + current.state + current.short_description);
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('number', current.number);
incidentGR.query();
while (incidentGR.next()) {
incidentGR.state = '9';
incidentGR.assigned_to = '';
incidentGR.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 01:12 AM
Hi
Why don't you do it with quering sys_id? Something like this
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('sys_id', current.sys_id);
incidentGR.query();
if(incidentGR.next()) {
incidentGR.setValue('incident_state','9');
incidentGR.setValue('assigned_to',"");
incidentGR.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2019 01:19 AM
Unfortunately, it does not work, even if it probably should...:(