- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2022 10:29 AM
Hi,
I have created a UI Action on Outage form which creates a KB Article using below script . The requirement is to Submit Knowledge Article in Review state , currently the KB Article is generating Draft state . Could you please help me with the requirement.
Thank you
Uttam Sai S
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.short_description = current.short_description;
kb.text = current.details;
kb.insert();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 08:50 AM
Hi @Uttam Sai ,
You can use UI action as below :-
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.workflow_state = 'review';
kb.short_description = current.short_description;
kb.text = current.details;
kb.insert();
There is on OOB business rule which change the workflow state of KB article as draft before insert. If you make it active false then your UI action will work.
The 2nd method is exclude the KB article created from UI action as below :-
UI action code :-
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.workflow_state = 'review';
kb.short_description = current.short_description;
kb.text = "Article From Outage:"+"\n"+current.details;
kb.insert();
BR edit in condition:-
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 09:10 AM
Hi @Uttam Sai ,
Please try below script
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.short_description = "Test SNOW COM";
kb.text ="Test SNOW COM";
kb.insert();
kb.workflow_state = 'review';
kb.update();
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 11:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 07:45 AM
Hi @Saurabh Gupta ,
Thank you so much for your response . I have tried the above script but is not working as expected .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 08:50 AM
Hi @Uttam Sai ,
You can use UI action as below :-
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.workflow_state = 'review';
kb.short_description = current.short_description;
kb.text = current.details;
kb.insert();
There is on OOB business rule which change the workflow state of KB article as draft before insert. If you make it active false then your UI action will work.
The 2nd method is exclude the KB article created from UI action as below :-
UI action code :-
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.workflow_state = 'review';
kb.short_description = current.short_description;
kb.text = "Article From Outage:"+"\n"+current.details;
kb.insert();
BR edit in condition:-
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2022 09:04 AM
Try below, you need to update the state after creating the kb :
var x = new GlideRecord('kb_knowledge');
x.initialize();
x.short_description = current.short_description;
x.text = current.details;
var id= x.insert();
var kb= new GlideRecord('kb_knowledge');
kb.get(id);
kb.state='review';
kb.update();
Raghav
MVP 2023