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. 




          • Related Articles

          • SDP - SDP MSP Integration using Custom Triggers

            This article helps users to integrate ManageEngine ServiceDesk Plus (SDP) - ServiceDesk Plus MSP (SDP MSP) using Custom triggers and Custom Schedules feature.  This is compatible with SDP Build - 11113 and SDP MSP Build - 10507 This will help the MSP ...
          • Instruction to Change Worklog owner under All Request, worklog owner From Tech A to Tech B

            Scenario      Worklogs assigned to Duplicate user / Incorrect user need to change all worklogs under request  to actual Technician.  Step 1 : Navigate to Report - > New Query Report and execute the below query.  Select workorder.workorderid ...
          • Mandate Fields in Worklog

            The below scrips mandates the fields in worklog.  1. Open a notepad 2. Paste the below scrips and save as CustomScripts.js  under <SDP-home>/custom/scripts folder (If you already have any scrips under existing CustomScripts.js, please take a backup) ...
          • How to add Resolution and Close Requests using Custom Trigger

            We can achieve it by using the custom trigger feature along with a python script. We can set a trigger based on which the script will execute, the script will add the resolution and set the status to 'Closed' You can modify the condition for the ...
          • Make the worklog description mandatory

            The below script mandates the worklog description.  1. Open a notepad. 2. Paste the below script and save as CustomScripts.js  under ManageEngine\ServiceDeskPlus-MSP/custom/scripts folder (If you already have any scripts under ...