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.

Add one year in knowledge base review date field

msc
Tera Contributor

Hi All,

 

I have requirement that

In knowledge article form we have one field called "Review Date" field.

When user submits the knowledge article the if that field is empty then I need to add one year in that date field.

Could you please help me on this.

1 ACCEPTED SOLUTION

@msc you can use if the field is available on the form, but I prefer doing it in BR.

 

In the above BR, add one more Condition like,

 

Review Date :: Is Empty

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

View solution in original post

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @msc 

If the review date field is date time field you can create a Before Insert/Update Business Rule like the one below.

 

Screenshot_2023-10-24-12-32-31-474-edit_com.android.chrome.jpg

(function executeRule(current, previous){

   var gdt = new GlideDateTime();

   gdt.addYearsUTC(365);

  current.u_review_date = gdt; //Change field name as per your configuration

})(current, previous);

 

If your field type is Date use the following script.

 

(function executeRule(current, previous){

 

   var gdt = new GlideDateTime();

 

   gdt.addYearsUTC(365);

 

  current.u_review_date = gdt.getDate(); //Change field name as per your configuration

 

})(current, previous);

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

Hi Anvesh,

Thanks for your response. Is it possible to use onsubmit client script here.

@msc you can use if the field is available on the form, but I prefer doing it in BR.

 

In the above BR, add one more Condition like,

 

Review Date :: Is Empty

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh