The CreatorCon Call for Content is officially open! Get started here.

Need to capture the time and date, when assigned to user is updated or added?

Feroz1
Tera Contributor

Hi Team, 

 

once the request is submitted and task is assigned to user. The below mentioned functionality should be implemented: 

 

  1. Created (OOB field - which is available in the instance)  – Which displays Date and time when the task is opened. 

  2. 1st Custom field( Assigned Date – create new field) – When the ticket is assigned to, we have to get the current updated date time and store it in custom field, If reassignment count is 0. ( Validation: If reassignment count is greater than ( > 0) then the custom field should not be updated.

  3. 2nd Custom field(Date Difference – create new field) – This will compare the created by field time duration with (1st custom field - Assigned Date) and will display the time duration in 2nd custom field.

Can any one help me on this task.

Thanks in advance.

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hey,

1. Created field works OOB, no config required for that.

2 & 3. For Assigned date field, you can have a Update-Insert/Before BR in place, with condition:

   Assigned to - changes and Assigned to - is not empty and Reassignment Count - is - 0

   In script you can just write

   var currDate = new GlideDateTime();

   var created = new GlideDateTime(current.getValue("sys_created_on");

   current.assigned_date = new GlideDateTime();

   current.date_difference = new GlideDuration(GlideDateTime.subtract(created , currDate));

 

Note: make sure your 3rd field is a duration field type

   

 

 

Best Regards
Aman Kumar

View solution in original post

7 REPLIES 7

Vaishnavi Lathk
Mega Sage
Mega Sage

Hi Priya,

Assuming you are having 1 custom date/time field on incident to hold it and assuming this should be set everytime the User Changes and when it is not empty

Before Update BR on incident table

Condition: assigned to Changes AND assigned to  is not empty

find_real_file.png

Script:

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

	// Add your code here
	current.dateTimeField = new GlideDateTime();

})(current, previous);

Regards
Vaishnavi Lathkar

Aman Kumar S
Kilo Patron

Hey,

1. Created field works OOB, no config required for that.

2 & 3. For Assigned date field, you can have a Update-Insert/Before BR in place, with condition:

   Assigned to - changes and Assigned to - is not empty and Reassignment Count - is - 0

   In script you can just write

   var currDate = new GlideDateTime();

   var created = new GlideDateTime(current.getValue("sys_created_on");

   current.assigned_date = new GlideDateTime();

   current.date_difference = new GlideDuration(GlideDateTime.subtract(created , currDate));

 

Note: make sure your 3rd field is a duration field type

   

 

 

Best Regards
Aman Kumar

@Aman Kumar  thanks for the Quick reply. It is working fine.

Hi @Aman Kumar S,

 

Is this possible in Flow Designer?

 

I have one subflow, where I need to get the Alert fields.

i.e. Alert Acknowledged at and Time to acknowledge the alert 

 

 

Thanks..!!