Submit Knowledge Article in Review state using UI Action

Uttam Sai
Tera Contributor

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();

 

1 ACCEPTED SOLUTION

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Uttam Sai ,

You can use UI action as below :-

GunjanKiratkar_0-1668876160096.png

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.

 

GunjanKiratkar_1-1668876253136.png

 

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:-

GunjanKiratkar_2-1668876648209.png

 

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

9 REPLIES 9

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

@Uttam Sai 

 

Have you tried above script?



Thanks and Regards,

Saurabh Gupta

Hi @Saurabh Gupta  ,

 

Thank you so much for your response . I have tried the above script but is not working as expected .

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @Uttam Sai ,

You can use UI action as below :-

GunjanKiratkar_0-1668876160096.png

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.

 

GunjanKiratkar_1-1668876253136.png

 

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:-

GunjanKiratkar_2-1668876648209.png

 

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

RaghavSh
Kilo Patron

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