- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2019 06:17 AM
Hi,
I have a script includes that calls a UI action.
The script includes and UI action together create a knowledge article.
Once the article is created, I would like the knowledge article to be created. Instead, it's just reloading the form of the page i'm on. I'd also like a message that says 'knowledge article created"..
Can anyone help with this redirect?
This is the Script Includes:
var CreateKB = Class.create();
CreateKB.prototype = Object.extendsObject(AbstractAjaxProcessor, {
createkb_from_story: function(){
var surveyId = this.getParameter('sysparm_storyId');
var kbtext = '';
var kbshort_description = '';
var gr = new GlideRecord('rm_story');
gr.addQuery('sys_id','IN', surveyId);
gr.query();
while(gr.next())
{
var link = '<a href="/rm_story.do?sys_id=' + gr.sys_id + '&table=' + gr.getRecordClassName() + gr.number + '</a>';
kbshort_description = gr.sprint.getDisplayValue();
kbtext = kbtext +link+'<br /> '+gr.short_description +'<br/><hr/>';
}
var kbart = new GlideRecord('kb_knowledge');
kbart.initialize();
kbart.short_description = 'Stories deployed in ' + kbshort_description;
kbart.kb_knowledge_base = 'ea3facf9db90f3441d194cd239961978';
kbart.topic = 'News';
kbart.text = kbtext;
kbSysId = kbart.insert();
},
type: 'CreateKB'
}
);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2019 06:51 AM
You can create a URL of created KB article and pass that url to:
gs.setRedirect("pass created URL");
https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_GS-setRedirect_O
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2019 06:36 AM
Hello sandy,
Add below line in your code:
kbSysId = kbart.insert();
action.openGlideRecord(kbSysId);
Note:
action.setRedirectURL ( 'http://www.mysite.com/mypage.htm' ) ;
action.setRedirectURL (new_record ) ;
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2019 06:45 AM
Hi, Thanks for the response. I added the line in bold, and it still is not opening / redirecting to the knowledge article created. Any other suggestions?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2019 06:51 AM
You can create a URL of created KB article and pass that url to:
gs.setRedirect("pass created URL");
https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_GS-setRedirect_O
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade