Create UI action button to extend the current KB record for 1 year

Shree22
Tera Contributor

Please help me  this is my script for extend button, click on the button then directly open KB_knowledge list view page. please help me find the solution.

Shree22_0-1691398507747.png

 

1 ACCEPTED SOLUTION

Hi,

Create like below:

Screenshot 2023-08-07 at 4.20.03 PM.png

 

Below is the script:

extendByYear(current);
function extendByYear(current){
	var nextDate = new GlideDateTime(current.valid_to);
	nextDate.addYearsUTC(1);
	current.valid_to = nextDate.getDate();
	current.update();
	action.setRedirectURL(current);
}
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

8 REPLIES 8

Anil Lande
Kilo Patron

Hi,

Can you please share where your UiAction should be visible?

What do you mean by extend by 1 year (from which date current valid_to date or from today?)

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Task: extend KB for 1 year button

Description: Create a UI action button to extend the current KB record for 1 year 

 

current Valid to date

how to achive that

 

Hi,

Create like below:

Screenshot 2023-08-07 at 4.20.03 PM.png

 

Below is the script:

extendByYear(current);
function extendByYear(current){
	var nextDate = new GlideDateTime(current.valid_to);
	nextDate.addYearsUTC(1);
	current.valid_to = nextDate.getDate();
	current.update();
	action.setRedirectURL(current);
}
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thank you for help