- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 10:07 AM
Hi,
I need to write a schedule job script.
Condition: If the application vulnerable item 'last found' date is greater than 30 days in the past, set the state of the application vulnerable item to closed.
Can any one help?
Thanks in advance.
Regards,
Juganta
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 06:41 AM
Write a new scheduled job with following script code.
You have to care about 2 things here, 1) field name of last found and 2) state close value
var grVI = new GlideRecord("sn_vul_vulnerable_item");
grVI.addQuery("last_foundRELATIVELT@dayofweek@ago@30");
grVI.query();
while(grVI.next()){
grVI.state = 7; // check the close state choice value for close
grVI.update();
}
Note: you can test this code with single record update only, just replace the while with If, If condition will execute once only ( no loop ) and check any record updated or not. After testing complete, then revert the If with while.
In case you have any doubt about the grVI.addQuery() then you can open the same table in list view and apply the 30 day condition on last found column and click on Run for result then copy that query using copy query action and past it in scheduled job.
Example of condition ( you have apply the similar on last found column in table ( sn_vul_vulnerable_item )
Let me know if it works for you or stuck some where.
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 10:59 AM
add the gs.info() inside the while loop and check if flow going inside.
and add the getRowCount() before the while();
and what's state value for close state. its 3 or 7
var grVI = new GlideRecord("sn_vul_app_vulnerable_item");
grVI.addQuery("last_foundRELATIVELT@dayofweek@ago@30");
grVI.query();
gs.info("Count->"+grVI.getRowCount());
while(grVI.next()){
grVI.state = 3;
grVI.update();
}
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 11:47 AM
Thanks Ashish.
It's working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2024 11:49 AM
good to know, please mark helpful also.
TIA
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution