Script to Auto close Preventive Maintenance Requests

Script to Auto close Preventive Maintenance Requests


This post describes the use of a python script to close  Preventive maintenance Requests 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 sending mailer campaigns to requesters at regular intervals or updating various attributes of requests periodically. You will find more information about this feature in the document available here.


Use case of customer:


User scheduled a Preventative maintenance task request at 2:PM and 10:PM ,once this 2 PM  Preventive Maintenance Tasks request reaches 11:00 PM it needs to be closed and notification needs to be sent to the respective team with the Description and subject. Same 10:00 PM Preventative maintenance task request task to be closed at 7:00 AM and notification needs to send once this is closed.


Execution steps:


1.Download the contents and paste it under \ManageEngine\ServiceDesk\integrations\Custom_scripts.


2. Go to Reports tab --> New query report --> copy the query to the query editor and run the report. Save the report in the folder. 


The query is available in the attachment (query.txt).


Modify the subject in the query


wo.TITLE = 'test subject' > This should be PM TASK subject


3. Configure 2 custom schedules at 11 pm and another one at 7 am.


Attached screenshot for reference.


4. In the configuration.json, configure the URL and technician key.


If you already have a  configuration.json file in the folder do not replace it.


A short guide on setting up python is available here.


                  New to ADSelfService Plus?

                    • Related Articles

                    • Script to Auto close Request when the status is Resolved for a particular number of days

                      For version 11 and above: -> In version 11, we only have the option to set the request Auto-close for a max of 10 days -> The below script will help you to extend the auto-closure time Execution steps: 1. Go to Reports--> New Query Report and run the ...
                    • Unable to save Preventive maintenance tasks

                      Issue: Unable to update just one PM task with more than 300 tasks. When tried to save the PM task, it simply throws "User does not have sufficient privilege". Cause: By default we would have restricted for these many tasks added in PM task. We can ...
                    • Preventive maintenance

                      This Report is used to export the list of Preventive maintenance configured in the application with the next schedule time. SELECT swo.WORKORDERID "Scheduled WOID", ti.SCHEDULE_TIME "Next Schedule Time", aau.FIRST_NAME "Requester", sdo.NAME "Site", ...
                    • How to auto share requests to groups specified in the request tasks.

                      This post described the use of a python script to share requests to groups specified in the tasks that are associated with a request.This script can be configured under Request custom triggers and you will find more information about this here. This ...
                    • Script to Auto close Request when the status is set to Resolved

                      This post describes the use of a python script to close requests that are 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 ...