I want to increase the valid to date by 1 year

Cupcake
Mega Guru

I have a need by our customer to update the Valid To date in KB articles by 1 year every time that KB article is updated.

So it should be looking at the updated (sys_updated_on) field and making the Valid To date (valid_to) 1 year from that date.

Should this best be handled thru a business rule.

1 ACCEPTED SOLUTION

Karen,



  If you are on eureka, copy this script


setValidTo();


function setValidTo(){


var gr= new GlideDateTime(current.sys_updated_on.getDisplayValue());


gr.addYears(1);


current.valid_to=gr.getDate();


}



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

25 REPLIES 25

Thank you I should have removed that part of it. I actually did an Insert and Stay from another business rule on the knowledge table. And in reference to Abhinay's comment, should this be an onBefore client script.


Karen,



  This script needs to be placed in an onBefore function that will be automatically created in the script section when you create a business rule.



Thanks,


Abhinay


Karen,



See the below snapshot, it should be enclosed in a function


find_real_file.png



Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


I changed the Business rule it still did not work:



find_real_file.png



find_real_file.png


Which release are you on? F, G, H?


Sorry Abhinay I just have mentioned that in the beginning, we are only on Eureka - but moving to Helsinki in a few months.



I can't wait either.



Thanks,


Karen