Case to incident work_notes

M_iA
Kilo Sage

We use the case management module in our business and we have users that have the case agent roles, but dont have ITIL.

From cases, we create related incidents where something is broken and those are assigned to our engineers who fix the issues.

We have business rules set up that copy additional comments and work notes from the case to the incident.

However, there are some circumstances where an agent who doesnt have ITIL will add a work note and because they dont have ITIL, the BR to copy the work note across doesnt write as they dont have the permission to do so.

 

What would you suggest as best way forward to resolve this and allow those non ITIL users to be able to add work_notes which copy across?

1 ACCEPTED SOLUTION

Hi @M_iA,

 

Thanks for sharing. Based on the conversation below, I would not setWorkflow(false).

 

Can you share 'when' the Business Rule runs. Is it a before or after? I would actually run this as Async for numerous reason, not least because when running as async it not only prevents holding the current users session, but it will also be processed by a different thread handled by the system user.

 

Can you set the 'When' field under the 'When to run' tab of the Business Rule to Async and confirm please.

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

View solution in original post

12 REPLIES 12

@Ankur Bawiskar- Thanks, this does work. We have set the order to 10000 though as we need other BRs to run. But by doing this, we need to be aware of this as could cause us issues with the BRs being set to stop on work notes being added. Is this the right way to achieve this?

@M_iA 

Glad to know that my solution worked.

Please mark my response as correct and close the thread.

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

@M_iA 

it should not impact ideally as you just disabling the query BR i.e. telling the GlideRecord not to run the query BR during your query

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

Robbie
Kilo Patron
Kilo Patron

Hi @M_iA,

 

This is not an uncommon request or use case and should be possible without providing any additional rules.

There seems to be a slight issue as to what or 'who' is calling and executing the write operation. This should be possible based on the asusmption that the business rule should be executed by the system.

 

How is are the additional comments or work notes being set?

Is the current.comments.setJournalEntry() method being used?

 

https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server_legacy/c_GlideElementAPI#r_Gli...

 

You may want to check and confirm what is running that business rule and how the comments are being added.

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

Hi @Robbie , here is the code:

 

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

	var caseWorknotes = current.work_notes.getJournalEntry(1);
	var relIncident = new GlideRecord('incident');
	relIncident.addQuery('sys_id', current.u_parent_incident);
	relIncident.query();

	if(relIncident.next()){
		// there could be more than one			
		if (caseWorknotes.contains(relIncident.number.toString())) {
			current.work_notes.replace('');
		} else {
			relIncident.work_notes = current.number + ' - '+caseWorknotes;
			relIncident.update();
		}
	}
})(current, previous);