Time Card not being created from Time Worked task


OOB, when creating a Time Worked task related to an incident, a time card will be automatically created if the user assigned to the Time Worked task is on the additional_assignee_list field of the incident.

If we have a before business rule on the Time Worked table to add the assigned user to the additional assignee list on the incident, it is expected that when the Time Card is being processed, a time card is created. However, the time card is not created as the TimeCardUtil script include is still picking up the previous additional assignee list that does not contain yet the new user.

Release or Environment

All releases.


TimeCardUtil script include uses the getRefRecord() method to get the Incident record from the Time Worked task.

 TimeCardUtil.updateTimeCardFromTimeWorked = function(timeWorked) {
	var autoUpdate = GlideUser.getUserByID(timeWorked.getValue('user')).hasRole('timecard_user');
	if(!autoUpdate || timeWorked.task.nil())
		return false;
	var task = timeWorked.task.getRefRecord();
	var assginedTo = task.getValue('assigned_to');
	var additionalAssigneeList = task.getValue('additional_assignee_list');
	var userId = timeWorked.getValue('user');
	autoUpdate = assginedTo == userId || (JSUtil.notNil(additionalAssigneeList) && additionalAssigneeList.contains(userId));

The at the time it is called, the referenced record is not yet updated and is still getting the previous additional_assignee_list values.


This is the OOB expected behavior when using getRefRecord() method.

As an alternative, using GlideRecord to get the record from the database instead of getRefRecord will get the latest additional_assignee_list, and will have the values updated from the before business rule.