Set a Catalog Item variable on Task Closure

vivek72
Tera Guru

Hi,

 

I have catalog item with 2 variables i.e. Start Date and End Date .

From this item, I have 2 reqs. as below:

1. New variable var1 (radio button) should be populated as success if Task creation date is 5 days before Start Date else failure.

2. New Variable var2 should be populated as success if  var1 is success and Task closed date is before End Date else failure.

 

please let me know how shall we implement this if it's feasible to do .

 

thanks,

Vivek

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @vivek72 you can create 2 client scripts on request table like below

1. Create a on Load client script to set start date for success/failure

  var getStartDate = new Date(g_form.getValue('variables.start_date'));// make sure variable names are correct
  alert(getStartDate);
var todayDate = new Date();
var timeDiff = Math.abs(todayDate.getTime() - getStartDate.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
alert(diffDays);
if(diffDays <= 5)
{
    alert("less than 5 days");
    g_form.setValue("variables.variablename",'success'); //
}
else
{
    alert('more than 5 days');
    g_form.setValue("variables.variablename",'failure'); //
}
 
2. create onSubmit client script to set end date
  var getEndDate = new Date(g_form.getValue('variables.end_date')).getTime();
  alert(getEndDate);
var closedDate = new Date(g_form.getValue('closed_at')).getTime(); // closed field captures closure time on req
 alert(closedDate);
if(closedDate <= getEndDate){

alert("closed date is less than get date");
}
else{
    alert("closed date is greater than get date");
}
 
 
Regards
Harish

View solution in original post

5 REPLIES 5

Hi @vivek72 yes you can put condition in your onLoad script to run only for this catalog and with condition state = closed so that it will not run for other request.

 

If my solution helped you please hit like and accept my solution .

Regards
Harish