AP cases first re-assigned date/time to be captured in a report

Tamilvanan T
Tera Contributor

Hi, 

I have a requirement for AP cases, the case is created & assigned to a team and when the case is re-assigned to another group for any details. the first re-assignment date/time of the case should be captured. 

I have created a date/time field to captured the deatils. It is working, but i wanted only the first re-assigned date/time details to be captured. I have established by using the re-assignment count. when re-assigment count is equals to 1 the date/time field should be captured. But it's not working. Is there a way to achieve this. 

Here's my business rule script:

Condition: Assignment group -> changes

assignment group-> not empty

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

    // Add your code here
    if(reassignment_count == 1){
    current.u_reassign_time = new GlideDateTime();
    }
})(current, previous);
 

 

2 REPLIES 2

Kawshal29
Tera Expert

Hello, 

As per my knowledge, the reassigment_count variable will not capture any count as the business rule executes differently for each insert/update on particular record. So the reassigment_count variable will never be equal to 1 unless until you assign 1 to it. (var reassigment_count = 1)

 

Here is the code that you can try to get the first reassignment date : 

When to run : before update

Conditions :  (same conditions as you have mentioned)

assignment_group --> changes

assignment_group --> not empty

 

 

Code : 

 

When we create a new record, initially the sys_created_on and sys_update_on fields have the same date/time value. When we update the record for the first time, the sys_updated_on changes from sys_created_on. 

In the code, we are checking if previous sys_updated_on value matches current sys_created_on value, then we are displaying the current sys_updated_on value (in your case first reassignment date/time).

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

	// To check if current created on date/time matches previous updated on date/time.

	if(previous.sys_updated_on == current.sys_created_on){ 
		gs.addInfoMessage(current.sys_updated_on);
	}


})(current, previous);

 

This code will give you the first reassignment date/time. Just assign that date/time value to the field you have created.

 

If you have any further questions, feel free to ask.

If you find this response helpful, give me a thumbs up and mark it as correct.

 

Thank you. 

KS

Kawshal29
Tera Expert

Hello @Tamilvanan T , 

 

If you find my response helpful, give me a thumbs up and mark it as correct. 
If you have any other doubts regarding this feel free to ask.

 

Thank you.

KS