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 ADManager Plus?

          New to ADSelfService Plus?

            • Related Articles

            • 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 ...
            • 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 ...
            • Script to Auto share request

              1. Download MSP_share_Request.zip from the attachment, extract it, and paste the same under ManageEngine\ServiceDesk Plus MSP\integrations\Custom_scripts.          # auto_share_MSP.py      # functions.py      # configuration.json 2. ...
            • Script to Auto merge requests with exact same subject

              Use case: Too many alerts for the same reason from a machine keeps generating multiple tickets in SDP MSP. You can use the below script to auto-merge the requests in the application. The Merged tickets description will be added as a note to the ...
            • Script: Auto merge tickets of similar subject and auto closes the ticket--> Used V1 API dont use

              Use case:   Too many alerts for the same reason from a machine keeps generating multiple tickets in SDP MSP.  You can use the below script to auto-merge the requests and auto close the ticket. What does this script do ? The Merged tickets description ...