Message in SCTASK Worknotes

nameisnani
Mega Sage

Hi Team , 

 

We have requirement that 

 

You can see here 2 sctasks got generated as per the WF . 

 

nameisnani_0-1697448046237.png

 

For eg 

1 . SCTASK0001 

2 . SCTASK0002

 

Our requirement , In the 2nd SCTASK Work notes we need to display message ( ' Please review the attachment on the # SCTASK Dynamically [ Here 1st SCTASK number should come ] ) .  

 

I.e - Please review the attachment on the SCTASK0001 

nameisnani_0-1697448396329.png

 

 

How achieve this requirement please help me with screenshots for better understanding . 

 

Thanks in advance

12 REPLIES 12

@nameisnani 

both catalog item and workflow should be in same scope. If they are not currently you need to ensure this and then the script I shared will work fine

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

@Ankur Bawiskar  , 

 

Both catalog and WF are in same scope . then also getting same error . 

 

nameisnani_0-1697515039811.png

 

 Business rule can we try here .

@nameisnani 

yes you can use before insert BR on sc_task

Condition: current.request_item.cat_item.name == 'Your Catalog Item Name Here'

Script:

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

	// Add your code here
	var gr = new GlideRecord("sc_task");
	gr.orderBy("sys_created_on");
	gr.addQuery("request_item", current.sys_id);
	gr.setLimit(1);
	gr.query();
	if (gr.next()) {
		current.work_notes = "Please review the attachment on the " + gr.number;
	}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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