- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 01:53 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 03:52 AM
Hi,
Create like below:
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);
}
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2023 04:31 AM
Glad to know your issue is resolve. Happy Learning 😊
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 11:55 PM
Hello @Anil Lande
Can you please explain me the code

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 12:08 AM
Hi @shaik23
Please check inline comments explaining each line.
extendByYear(current); // calling the function defined below
function extendByYear(current){ // function defination
var nextDate = new GlideDateTime(current.valid_to); // crate variable (object) of type GlideDateTime and initialize it with value selected in valid_to field
nextDate.addYearsUTC(1); // addYearsUTC is methode of GlideDateTime class, it add one year to the Date set previously
current.valid_to = nextDate.getDate(); // set the updated date to the field valid_to, getDate() returns date part form Date and Time
current.update(); // update the current record
action.setRedirectURL(current); // redirect to same form after saving record.
}
You can learn more about GlideDateTime API on below official documentation page.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 12:14 AM
Thanks for the reply very helpful