This post describes the use of a python script to close requests based on the last updated time and requests set in Resolved status using Custom Schedules.
What is 'Custom Schedules' ?
The Custom Schedules feature enables you to access any data in ServiceDesk Plus to perform customized actions periodically. Each custom schedule can associate Query Reports as arguments to a script file. You can even synchronize ServiceDesk Plus data with other third-party applications to perform various actions, such as send mailer campaigns to requesters at regular intervals or update various attributes of requests periodically.You will find more information about this feature in document available here.
Execution steps:
1. Go to Reports--> New Query Report and run the below query and save this report.
SELECT wo.WORKORDERID AS "Request ID", wo.TITLE AS "Subject", std.STATUSNAME AS "Request Status", wos.LAST_TECH_UPDATE AS "Last Update Time", ad.ORG_NAME AS "Account" FROM WorkOrder wo LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID LEFT JOIN AccountSiteMapping asm ON wo.SITEID=asm.SITEID LEFT JOIN AccountDefinition ad ON asm.ACCOUNTID=ad.ORG_ID
WHERE std.STATUSNAME like '%Resolved%' and extract(epoch from(now()::TIMESTAMP - to_timestamp(wos.LAST_TECH_UPDATE/1000)::TIMESTAMP))/3600/24 < 7
order by wos.workorderid limit 500;
This will give you the ID of requests under Resolved status and the last updated is before 7 days. You shall change the last updated number of days as per your requirement. Running the report under Reports - > New query report will show the requests matching the report criteria. Save the Report as Resolved Requests.
2. Download the script file and the function.py and place them in the location ManageEngine/ ServiceDeskPlus-MSP/ integration/custom_scripts folder.
(Note: Don't replace functions.py and configuration.json files if they already exist in that location)
3. Update the technician key and the application URL in the configuration.json file attached. The technician API key can be generated by clicking on the technician Profile icon in top right - > Generate API Key
4. Configure the schedule under Admin--> Custom Schedule
A short guide on setting up python is available here.