Tip #31: Track delays and capture causes for delay using Client Scripts in Qntrl

Tip #31: Track delays and capture causes for delay using Client Scripts in Qntrl



Overcoming project delays is a major concern for many businesses. Most industries like IT, manufacturing, transport, and construction work on defined time lines and any delay in completion might lead to cost overrun, compromised reputation, or even failed projects. To overcome this, monitoring instances of delay regularly, right from the initial phases of a project is essential.
 
Automating delay management is a recommended step as it eases central monitoring and reduces errors. To automate delay monitoring, Qntrl supports SLAs for every single stage. But, if you want to track time delays beyond individual stages—for a group of stages or an entire card—Client Scripts can be of help.
 
Client Scripts are coded by users to process existing data or add additional validations to data available in Qntrl. Let us now calculate the time delay using Client Scripts.
 
Business case
Donelly Constructions uses Qntrl to track the progress of their construction activities. They require to calculate the time difference between 2 given transitions to monitor the delay. If the calculated time limit is higher than 72 hours, the field ‘Reason for delay’ must be mandated to be filled by the user while closing the card.

Solution
  • Create a form with 2 Date & Time fields.
  • Configure the blueprint transition’s After section with Update Fields to capture the time at which the transitions take place.
  • Code the Client Script to calculate the time difference between 2 transitions and if any delay is spotted, prompt the user to provide the reason for delay while performing the last transition.  

Sample configuration

Step 1: Create 2 Date & Time fields in forms to capture the completion time of transitions.
  • Here, 'Time of milling' and 'Time of testing' are the 2 fields used.
  • Turn off the visibility of these fields to restrict users from filling them during card creation.


Step 2: Record the exact completion time of transitions using Update Fields in Blueprints or Business Rules.
  • In the blueprint, configure the 2 transitions you want to find the time difference between with Update Fields in After section.
    • Note: Any 2 transitions other than the last transition can be configured here.
  • Set the action as ‘Time of milling’ = ‘Execution date’ and ‘Time of testing’ = ‘Execution date’.

  • In the final transition, configure During section with fields ‘Time of milling’, ‘Time of testing’, and ‘Reason for delay’ to prompt the user while closing the card.


Step 3: Find the time difference between 2 date and time fields,  Identify delay, and hold accountability using Client Scripts.

Configure the client script for the last transition with execution trigger as OnLoad.


  1. async function onLoad(forpage) {
  2.     //You can lock the fields to restrict users from changing the time value
  3.     current.Layout.Fields.<select-first-date-field-here> .lock();
  4.     current.Layout.Fields. <select-second-date-field-here> .lock();
  5.     var request_time = current.Job.getValue(current.Blueprint.Transition.Fields. <select-first-date-field-here> .id);
  6.     var finished_time = current.Job.getValue(current.Blueprint.Transition.Fields. <select-second-date-field-here> .id);
  7.     //Calculating the time difference and validate it
  8.         var difference = (finished_time.value - request_time.value) / (1000 * 60 * 60)
  9.         if (difference >= 72) {
  10.             current.Blueprint.Transition.Fields.<select-reason-for-delay-field-here>.setMandatory(true);
  11.             current.Blueprint.Transition.Fields. <select-reason-for-delay-field-here> .show();
  12.         } else {
  13.             current.Blueprint.Transition.Fields. <select-reason-for-delay-field-here> .hide();
  14.         }   
  15.     }




Here, when performing the final transition, if the time difference is greater than or equal to 72 hours, the field ‘Reason for delay’ is set to mandatory. Else, if the time difference is less than 72 hours, the field will not be prompted for the user.  



Let us know if this business case is useful for you. You can view more such sample client scripts in our KB. If you have any unique requirements, comment below or email us at support@qntrl.com.