Close Ticket Business Rule [sc_task]

Tracey Wilmot
Tera Contributor

Hi all,

I'm trying to generate the duration of a SC Task or RITM.  I found the following KB article:

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0684036

I've updated the Close Ticket business rule as it suggests but the the Business Duration field is not populating...

find_real_file.png

find_real_file.png

Any help greatly appreciated.  I would like to do the same for RITMs too.

Many thanks

Tracey

1 ACCEPTED SOLUTION

Dan H
Tera Guru

Hi Tracey,

Could you try this script instead?

current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.work_end.getDisplayValue(),false);

 

Let me know the outcome.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

View solution in original post

11 REPLIES 11

Dan H
Tera Guru

Hi Tracey,

Could you try this script instead?

current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.work_end.getDisplayValue(),false);

 

Let me know the outcome.

Please mark my answer as Correct/Helpful based on impact

Regards,

Dan H

It worked!  Thank you so much!

 

find_real_file.png

I don't suppose you know about a business duration on requested items [sc_req_item]?  It mentions it in the KB article but I'm not sure what is required.

 

Thanks again

Tracey

Np Tracey.

I think it would be quite similar, but this time create a new business rule like this:

find_real_file.png

find_real_file.png

 

Script:

	current.active = false;
	if (current.closed_by.nil())
		current.closed_by = gs.getUserID();

	if (current.closed_at.nil())  {
		current.closed_at = gs.nowDateTime();
		current.business_duration = gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),false);
		current.calendar_stc = gs.dateDiff(current.opened_at.getDisplayValue(),current.closed_at.getDisplayValue(),true);
	}

 

Hope that helps.

 

Thanks Dan!

It is definitely doing something as Business duration was blank before, now it is coming over as 0 seconds...

find_real_file.png