Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Actual start and end date in change request should be in between change request planned start date a

Tulasiram1
Kilo Guru

Actual start and end date in change request should be inbetween change request planned start date and planned end date

1 ACCEPTED SOLUTION

Tulasiram1
Kilo Guru

Write Before BR update.

 

Tulasiram1_0-1676629300487.png

 

View solution in original post

4 REPLIES 4

shyamkumar VK
Kilo Patron

Hello @Tulasiram1  ,

you need to Write on Submit Client Script for this , use below code 

function onSubmit() {
  // Get the planned start date and end date
  var plannedStart = g_form.getValue('planned_start_date'); // update with your field
  var plannedEnd = g_form.getValue('planned_end_date');//update with your field

  // Get the actual start date and end date
  var actualStart = g_form.getValue('start_date'); //update with your field
  var actualEnd = g_form.getValue('end_date'); //update with your field

  // Check if the actual start date is before the planned start date
  if (actualStart < plannedStart) {
    g_form.showFieldMsg('start_date', 'Actual start date cannot be before the planned start date', 'error');
    return false;
  }

  // Check if the actual end date is after the planned end date
  if (actualEnd > plannedEnd) {
    g_form.showFieldMsg('end_date', 'Actual end date cannot be after the planned end date', 'error');
    return false;
  }

  return true;
}
Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

I have written ths script then I am trying to test. I am getting error while filling planned start date.

Tulasiram1_0-1676286562647.png

 

Hello @Tulasiram1  ,

Did you updated your backend field values correctly in the Script , also can you please share the Code screenshot which you have written in CS

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Tulasiram1
Kilo Guru

Write Before BR update.

 

Tulasiram1_0-1676629300487.png