KB article validation

pk2184046
Tera Expert

Screenshot 2024-05-09 125321.pngScreenshot 2024-05-09 125422.pngimage.pngHi there,

Recently I found an issue that the kb article validation is happening when we are creating the article it will give alert msg if the valid to date is selected less than the current or greater than 365 days. it is working fine till there.

Initially the valid to date will set exactly after 365 days of creation.

Example: Kb article is created today 5/9/2024 it will set valid to date as 5/8/2025.

Here is the issue.

after the valid to date expires the kb article will be set as to draft state. Whenever we are again publishing the artice the valid to date is not validating like previously when it was created. Attached screenshot for that.

we can able to select the previous date as well which it should not alloww.

Kindy help me.

 

This is the client script on change we are using:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
    var currentDateObj = new Date();
    var currentDateStr = formatDate(currentDateObj, g_user_date_format);
    var currentDateNum = getDateFromFormat(currentDateStr, g_user_date_format);
    var validto = g_form.getValue('valid_to');
    var validtoNum = getDateFromFormat(validto, g_user_date_format);
    var validtodate = new Date(g_form.getValue('valid_to'));
    var diff = validtoNum - currentDateNum;
   
    if(validtodate < currentDateObj){
        alert('Valid to cannot be past date');
       g_form.setValue('valid_to',oldValue );
   
    }
    else if(diff>=31536000000){
        alert('You cannot select more than 365 days from today.');
        g_form.setValue('valid_to',oldValue );
     
    }
   //Type appropriate comment here, and begin script below
   
}
0 REPLIES 0