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.

Default date field from another date field on record producer

Andre241
Tera Contributor

Hello,

 

I have 2 variable date fields called "due_date" & "actual_review_due_date". I need "actual_review_due_date" to be auto-populated with "due_date" value when filled out. I also want actual_review_due_date field to be editable. Thank you.

1 ACCEPTED SOLUTION

davitvoski
Tera Expert

1. Configure the two date fields as a variable in the record producer.
2. Create a Catalog Client script, with onChange type with the variable name being the due date.
3. Paste the following in the client script

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   g_form.setValue("actual_review_due_date", newValue);

   //Type appropriate comment here, and begin script below
   
}

4. You should now have the actual review due date populate with the same value as the due_date. The actual review due date will be editable as well as we have not set it to read-only.

davitvoski_0-1710442661110.png

 


Please accept the solution and mark it as helpful, if this helped you resolve your issue.
- Davit

View solution in original post

4 REPLIES 4

davitvoski
Tera Expert

1. Configure the two date fields as a variable in the record producer.
2. Create a Catalog Client script, with onChange type with the variable name being the due date.
3. Paste the following in the client script

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

   g_form.setValue("actual_review_due_date", newValue);

   //Type appropriate comment here, and begin script below
   
}

4. You should now have the actual review due date populate with the same value as the due_date. The actual review due date will be editable as well as we have not set it to read-only.

davitvoski_0-1710442661110.png

 


Please accept the solution and mark it as helpful, if this helped you resolve your issue.
- Davit

Thank you. It worked.

James Chun
Kilo Patron

Hi @Andre241,

 

I am assuming that you don't have to auto-populate the 'due_date' from the 'actual_review_due_date'.

If so, you can write an onChange Catalog Client script on the 'due_date' variable.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading) {
      return;
   }

   g_form.setValue('actual_review_due_date', newValue);
   
}

 

Cheers