- 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-03-2024 10:10 AM
Hi @jugantanayak ,
Can you share the table name for this application record, you can apply the condition in the list view and add the same query in scheduled job and get those record.
-Thanks,
AshishKMishra
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-04-2024 04:40 AM
Hi Ashish,
Thanks for your reply.
Table name is: sn_vul_vulnerable_item
- 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:48 AM
Hi Ashish,
Thanks for your reply.
I have written below code but when i have applied Execute button, nothing is happening.
Or am i doiing anything wrong?
Code: