- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 09:59 AM
I have a need to update KB article using a link in email notification sent to itil users. Once the user clicks on the email link, it should updated the KB article with an expiry date of (current date + 1 year). How can this be set up? Please help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 10:48 AM
I am able to achieve this by creating a new UI page 'newUIpagename' with example code as below and using the UI page url in the email link, '<a href="https://' + instance_name + '.service-now.com/newUIpagename.do?sysparm_kb_id=' + current.sys_id + '&sysparm_action=update"' >'
HTML field:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_kb" value="${sysparm_kb_id}" />
<g:evaluate var="jvar_unwrapped_url" jelly="true">
var kb = RP.getParameterValue('sysparm_kb_id');
var kb_action = RP.getParameterValue('sysparm_action');
var link = '';
var kb_article = new GlideRecord('kb_knowledge');
kb_article.addQuery('sys_id', "${sysparm_kb_id}");
kb_article.addQuery('workflow_state', "published");
kb_article.query();
if(kb_article.next()){
if (kb_action == "update") {
kb_article.setValue(//update the field values);
kb_article.update();
gs.addInfoMessage(kb_article.getDisplayValue() + ' is updated. Redirecting to KB Article');
}
if(kb_action == "retire") {
kb_article.setValue('workflow_state','retired');
kb_article.update();
gs.addInfoMessage(kb_article.getDisplayValue() + ' is retired. Redirecting to KB Article');
}
}
gs.setRedirect("kb_knowledge.do?sys_id=" + kb_article.sys_id);
</g:evaluate>
${gs.getMessage("Redirecting to KB article")}...
</j:jelly>
Client Script field:
document.location.href = "$[JS:jvar_unwrapped_url]";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 10:03 AM
Hi @Sree21
Please refer below Community Post with solution. Issue is almost same.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 10:17 AM
Thank you for the reply. I am looking for a solution without using inbound action for the reply email. When the URL link on the notification is clicked, it should update the record without having to send an email reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2022 10:30 AM
Hi @Sree21
Without inbound action how will the reply connect with the instance. How will Instance know that Link was Clicked.
I don't think its possible without inbound action or manual sets to update.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2022 10:48 AM
I am able to achieve this by creating a new UI page 'newUIpagename' with example code as below and using the UI page url in the email link, '<a href="https://' + instance_name + '.service-now.com/newUIpagename.do?sysparm_kb_id=' + current.sys_id + '&sysparm_action=update"' >'
HTML field:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_kb" value="${sysparm_kb_id}" />
<g:evaluate var="jvar_unwrapped_url" jelly="true">
var kb = RP.getParameterValue('sysparm_kb_id');
var kb_action = RP.getParameterValue('sysparm_action');
var link = '';
var kb_article = new GlideRecord('kb_knowledge');
kb_article.addQuery('sys_id', "${sysparm_kb_id}");
kb_article.addQuery('workflow_state', "published");
kb_article.query();
if(kb_article.next()){
if (kb_action == "update") {
kb_article.setValue(//update the field values);
kb_article.update();
gs.addInfoMessage(kb_article.getDisplayValue() + ' is updated. Redirecting to KB Article');
}
if(kb_action == "retire") {
kb_article.setValue('workflow_state','retired');
kb_article.update();
gs.addInfoMessage(kb_article.getDisplayValue() + ' is retired. Redirecting to KB Article');
}
}
gs.setRedirect("kb_knowledge.do?sys_id=" + kb_article.sys_id);
</g:evaluate>
${gs.getMessage("Redirecting to KB article")}...
</j:jelly>
Client Script field:
document.location.href = "$[JS:jvar_unwrapped_url]";