Mandate Fields in Worklog

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)
3. Please clear the browser cache once and then try to add a worklog

 ************ Mandate Time Taken to Resolve Field **************

jQuery(document).on('click',"#addWorkLogButton",function(){
    var fields = ["timespenthrs", "timespentmins"];
    var isMandate = true;
    for(var i=0;i<fields.length;i++){
      var fld_val;

      if(fields[i]=="timespenthrs" || fields[i]=="timespentmins")
      {
        fld_val = jQuery("[name='"+fields[i]+"']").val();
      }

      if(fld_val != "" && fld_val != "null" && fld_val.trim()!=""){
        isMandate = false;
      }
    }
    if(isMandate){
      alert("Please enter the Time Taken to Resolve");
      return false;
    }
    return true;
  }); 

************** Mandate Description **************


jQuery(document).on('click',"#addWorkLogButton",function(){
    var fields = ["description"];
    var isMandate = false;
    for(var i=0;i<fields.length;i++){
      var fld_val;
      if(fields[i]=="description")
      {
        fld_val = jQuery("textarea[name='"+fields[i]+"']").val();
      }
      else{
        fld_val = jQuery("[name='"+fields[i]+"']").val();
      }
      if(fld_val == "" || fld_val == "null"){
        isMandate = true;
      }
    }
    if(isMandate){
      alert("fill worklog and description");
      return false;
    }
    return true;
  }); 



There is already a feature developed by SDP that may serve the customer's requirement. Please check SDP Issue ID: 70934 for more information.
This feature has been released in SDP - 10001 and it will be available for us when we release MSP 10.5



          • Related Articles

          • Make the worklog description mandatory (Applicable only till 10536)

            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 ...
          • FAFR - How to mandate field when SLA is overdue

            1. Under Admin >> Incident Template >> Edit the template in question 2. Choose field and form rules and apply the below script On Form Submit var duebyDate = $CS.getValue("DUEBYDATE"); var currentDate = new Date(); if(currentDate>duebyDate) { ...
          • 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 ...
          • Query to show both task comments and worklog comments

            MSSQL: SELECT "taskdet"."TASKID" AS "Task ID", "taskdet"."TASKID" AS "Task ID", "wotask"."WORKORDERID" AS "RequestID", cd.CATEGORYNAME AS "Request Category",  "taskgroup"."QUEUENAME" AS "Group", "taskowner"."FIRST_NAME" AS "Owner", "taskdet"."TITLE" ...
          • Query to show Last added worklog of a ticket _MSSQL

            MSSQL: SELECT wo.WORKORDERID AS "Ticket Number", pd.PRIORITYNAME AS "Priority", cd.CATEGORYNAME AS "Category", qd.QUEUENAME AS "Group", ti.FIRST_NAME AS "Technician", aau.FIRST_NAME AS "Requester", Wo.title "Subject", wotodesc.FULLDESCRIPTION AS ...