- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 06:28 AM
Hi everyone I have a requirement to make a UI Action that when clicked, it will redirect the user to the knowledge article form so that the user can create a new article, does anyone know's how to make this redirect dinamic ?
(without a hardcoded url)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 09:03 AM
Thanks,
That UI action you copied is specific to the 'Incident Management for Service Operations Workspace' scope, so if you've copied the code and are running it in a different scope (for example global) you'll end up with an error and the UI action failing.
Change
new SOWIncidentKnowledgeUtils().getNewKnowledgeArticleLink(current);
to
new global.IncidentKnowledgeUtils().getNewKnowledgeArticleLink(current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 06:43 AM
Depending on the plugins you've installed, there a few examples of directing a user to a knowledge article.
For example, incident has 'Create Knowledge' which you could copy the logic of
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 07:03 AM
Yeah I tried it but for some reason when I click the UI Action it redirects me to the UI Action form instead of redirecting me to the KB article

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 07:10 AM
Share your code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 07:11 AM
var issueLabel;
var resolutionLabel;
if (GlidePluginManager.isActive('com.snc.incident.knowledge')) {
var targetURL = new SOWIncidentKnowledgeUtils().getNewKnowledgeArticleLink(current);
if (targetURL) {
action.setRedirectURL(targetURL);
} else {
gs.error("Could not get target URL for the Knowledge Article");
}
} else {
var sub = gs.getProperty('glide.knowman.submission.workflow');
issueLabel = gs.getMessage("Issue");
resolutionLabel = gs.getMessage("Resolution");
if (sub == 'true')
submitCandidate();
else
submitDirect();
}
function submitDirect() {
var kb = new GlideRecord("kb_knowledge");
kb.source = current.sys_id;
kb.short_description = current.short_description;
kb.sys_domain = current.sys_domain;
kb.text = "<p><strong>" + issueLabel + "</strong> - " + current.description + "</p> <p><strong>" + resolutionLabel + "</strong> - " + current.close_notes + "</p>";
kb.workflow_state = 'draft';
kb.kb_knowledge_base = gs.getProperty("glide.knowman.task_kb", "dfc19531bf2021003f07e2c1ac0739ab");
kb.insert();
}
function submitCandidate() {
var gr = new GlideRecord('kb_submission');
gr.parent = current.sys_id;
gr.short_description = current.short_description;
gr.sys_domain = current.sys_domain;
gr.text = "<p><strong>" + issueLabel + "</strong> - " + current.description + "</p> <p><strong>" + resolutionLabel + "</strong> - " + current.close_notes + "</p>";
if (gr.insert())
gs.addInfoMessage(gs.getMessage('KB submission {0} was created and attached to the parent record {1}', [gr.getDisplayValue(), current.getDisplayValue()]));
}