Restrict knowledge article validity

Atchutaram
Tera Contributor

Hi Team,

               We have set the knowledge article validity to one year, when any user tries to change it more than one more, it should not allow him to do so. the one year date only should be only populated. The field should not be read only.

 

How can I do this?

 

 

1 ACCEPTED SOLUTION

Hi @Atchutaram 

 

This is my weak area :(. I am not a developer. 

 

@Jaspal Singh  @Sohail Khilji any help here.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

8 REPLIES 8

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Atchutaram 

 

So you mean, it should not be more than 1 year from Now / created date?

 

You can put the UI policy on same.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi AG,  

               How can we do this Ui policy based on date?  The validity date should not cross one year, how can we do this. I have tried of making the field read only but our customer dont want like that. they want the date should be changed more than one year.

Hi @Atchutaram 

 

https://www.servicenow.com/community/developer-articles/no-code-date-validations-through-catalog-ui-...

 

https://www.servicenow.com/community/itsm-forum/how-to-restrict-date-field-range-upto-12-months-from...

 

https://www.servicenow.com/community/itsm-forum/prevent-user-from-entering-an-end-date-that-is-30-da...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG  I am writing this script on on change client script. This is working but when we save the form or submit the valid to is still changing and getting the form saved.

 

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

var validityField = 'valid_to';
   var onYearValidity = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
var newValidity = new Date(newValue);

   if(newValidity > onYearValidity) {
      // g_form.clearValue(validityField);
       g_form.showErrorBox(validityField,'Valid to date must be within a year from today');
   } else {
       g_form.hideErrorBox(validityField);
   }

}