How to attach article on RITM or SCTASK based on catalog item

Harsha Reddy
Tera Contributor

Hi Community,

How we can attach the articles automatically on RITM or SCTASK form related link based on catalog item. How can we achieve this can you please any one help me on this.

 

Thanks in Advance,

Harsha Reddy 

1 ACCEPTED SOLUTION

@Harsha Reddy 

I found it

BR: After Insert on sc_req_item

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("m2m_kb_task");
	gr.addQuery("sc_cat_item", current.cat_item);
	gr.query();
	while(gr.next()) {
		var rec = new GlideRecord("m2m_kb_task");
		rec.initialize();
		rec.setValue("task", current.sys_id);
		rec.setValue("kb_knowledge", gr.kb_knowledge);
		rec.insert();
	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi,

so knowledge articles are attached to catalog items.

those you want to see under RITM

you can use this script in after insert BR on RITM table

1) query sc_2_kb with catalog item and iterate and insert record into the related list table

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Can you please explain how to write BR?

Hi,

I am not able to find the related list of Attached knowledge on RITM form

Is that a custom one?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Harsha Reddy 

I found it

BR: After Insert on sc_req_item

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("m2m_kb_task");
	gr.addQuery("sc_cat_item", current.cat_item);
	gr.query();
	while(gr.next()) {
		var rec = new GlideRecord("m2m_kb_task");
		rec.initialize();
		rec.setValue("task", current.sys_id);
		rec.setValue("kb_knowledge", gr.kb_knowledge);
		rec.insert();
	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Harsha Reddy 

If my response helped please mark it helpful as well.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader