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. ...
                      • Close the request upon adding a note.

                        Kindly follow the steps mentioned below: 1) Go to Admin >> Developer Space >> Custom Function >> Global Functions >> Copy & Paste the attached GF_Content.txt and save it with a name. Update the URL and technician key as per your instance. Refer to ...
                      • Query to show PM task details with Next schedule and last ran time (MSSQL & PGSQL)

                        Tested in Build PGSQL (14300) or MSSQL (14306) Next schedule time : SELECT swo.WORKORDERID "PM Task ID", adef.org_name "Account", sdo.name "Site", ti.SCHEDULE_TIME "Next Schedule Time", aau.FIRST_NAME "Requester", dpt.DEPTNAME "Department", ...