
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 08:39 AM
I need to have a script action set a fields value "current_status" to a specific value "Complete - Auto Closed". Can anyone let me know how this can be written?
Thanks so much,
Edwin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 01:02 PM
Hi Edwin,
Your scheduled script looks fine as per screen shot. However the code you pasted, does not have correct syntax for gs.eventQueue() function in schedule script.
In your script action just do this:
closeRecord();
function closeRecord() {
current.current_status = 'Complete - AutoClosed';
current.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 09:24 AM
Script action should be triggered by a Event, you may have to pass the parameters. Glide the table and update the field.
Can you please elaborate the scenario so that I can provide you exact solution, because this can be done in many ways .
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 09:42 AM
I'm trying to close records that are in a particular status of "Requestor to Complete" and have not been updated for 48 hours. So I've written a scheduled Script that triggers an event. That event is used to trigger the script action. Below are screen shots of everything
This script below could potentially be written better, but it's what I've came up with since I'm fairly new to scripting. I only want to close records where the "audience" field is equal to 'Internal' and the status is equal to "Requestor to Complete" and the record has not been updated for 48 hours. The script below is excluding everything to only get me the condition I just described.
var gr= new GlideRecord("x_hemas_connectus2_x_hemas_connectus_connectus");
gr.addEncodedQuery('sys_updated_on>javascript:gs.daysAgoStart(2)');
gr.addQuery('audience','!=','Client');
gr.addQuery('audience','!=','Other');
gr.addQuery('current_status','!=','Complete');
gr.addQuery('current_status','!=','Requestor Canceled');
gr.addQuery('current_status','!=','Closed-CCCU Reported');
gr.addQuery('current_status','!=','Clarification Needed');
gr.addQuery('current_status','!=','Draft');
gr.addQuery('current_status','!=','Acknowledged');
gr.addQuery('current_status','!=','In Progress');
gr.addQuery('current_status','!=','Client Request Not Met');
gr.addQuery('current_status','!=','Rebuttal Submitted');
gr.addQuery('current_status','!=','Rebuttal Rejected');
gr.addQuery('current_status','!=','New');
gr.query();
while(gr.next()){
gs.eventQueue('x_hemas_connectus2.closeinternal');
}
closeRecord();
function closeRecord() {
var gr = new GlideRecord("x_hemas_connectus2_x_hemas_connectus_connectus");
current.current_status = 'Complete - AutoClosed';
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 10:40 AM
You have to pass parameters when you call an event
Scheduled Job Script:
var gr= new GlideRecord("x_hemas_connectus2_x_hemas_connectus_connectus");
gr.addEncodedQuery('sys_updated_on>javascript:gs.daysAgoStart(2)');
gr.addQuery('audience','!=','Client');
gr.addQuery('audience','!=','Other');
gr.addQuery('current_status','!=','Complete');
gr.addQuery('current_status','!=','Requestor Canceled');
gr.addQuery('current_status','!=','Closed-CCCU Reported');
gr.addQuery('current_status','!=','Clarification Needed');
gr.addQuery('current_status','!=','Draft');
gr.addQuery('current_status','!=','Acknowledged');
gr.addQuery('current_status','!=','In Progress');
gr.addQuery('current_status','!=','Client Request Not Met');
gr.addQuery('current_status','!=','Rebuttal Submitted');
gr.addQuery('current_status','!=','Rebuttal Rejected');
gr.addQuery('current_status','!=','New');
gr.query();
while(gr.next()){
gs.eventQueue('x_hemas_connectus2.closeinternal',gr,gr);
}
Script action:
closeRecord();
function closeRecord() {
var gr1 = new GlideRecord("x_hemas_connectus2_x_hemas_connectus_connectus");
gr1.get(event.param1.sys_id);
if(gr1.next()){
gr1.current_status = 'Complete - AutoClosed';
gr1.update();
}
}
P.S Mark Correct, Hit Like/Helpful if you think my answer is worthy.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2017 01:02 PM
Hi Edwin,
Your scheduled script looks fine as per screen shot. However the code you pasted, does not have correct syntax for gs.eventQueue() function in schedule script.
In your script action just do this:
closeRecord();
function closeRecord() {
current.current_status = 'Complete - AutoClosed';
current.update();
}