Script to add worklog using custom schedule

Script to add worklog using custom schedule

What is a Custom Schedule?

Custom Schedules are actions scheduled on a specific date and time with or without repeat frequency. The actions are specified in a customized script file. Any data from ServiceDesk Plus can be sent to the script through Query Reports.

Create a new custom schedule with a unique Schedule Name. Mention the command to execute the script in the Executor field. Associate the required Query Reports as Arguments. Mention the Start Date & Time when the action should take place. Schedule the action by specifying the Repeat interval. Enable/Disable a custom schedule as preferred.


Pre-Requisites

1. Python should be installed in the server with the Request package.  You can find the instructions here

Steps

1. Download the attachment and place it under ManageEngine\ServiceDeskPlus-MSP\integration\custom_scripts

2. Edit addWorklog.py and update the URL, technician key. 

3. Under Reports Tab >> New Query Report >> Run the below query >> Save the report 

SELECT "wo"."WORKORDERID" AS "Request ID", "ad"."ORG_NAME" AS "Account", "sdo"."NAME" AS "Site", "ac"."CONTRACTNAME" AS "Contract Name"  FROM "WorkOrder" "wo" LEFT JOIN "SiteDefinition" "siteDef" ON "wo"."SITEID"="siteDef"."SITEID" LEFT JOIN "SDOrganization" "sdo" ON "siteDef"."SITEID"="sdo"."ORG_ID" LEFT JOIN "AccountSiteMapping" "asm" ON "wo"."SITEID"="asm"."SITEID" LEFT JOIN "AccountDefinition" "ad" ON "asm"."ACCOUNTID"="ad"."ORG_ID" INNER JOIN "WorkorderToContract" "wtc" ON "wo"."WORKORDERID"="wtc"."WORKORDERID" LEFT JOIN "AccountContract" "ac" ON "wtc"."CONTRACTID"="ac"."CONTRACTID" INNER JOIN "WorkOrderStates" "wos" ON "wo"."WORKORDERID"="wos"."WORKORDERID" WHERE (wo.ISPARENT='1') and sdo. wo.workorderid in (64,63)

The above query will filter the request based on the id provided which also has an active contract. The work logs will also be added to the same tickets. 

4. Under Admin >> Custom Schedule >> Create a new schedule to run >> The report needs to be added as arguments. 




                  New to ADSelfService Plus?