How to know when "Assigned to" has been registered for the first time

Kentaro Numata
Tera Guru

Happy new year everyone. It's Kentaro.
Thank you for your continued support this year.

I'm looking for a way to know when "Assigned to" has been updated for the first time.
Because I want to update a specific Date column when "Assigned to" is updated for the first time.
Isn't there a similar way to know when a record was first registered using a function?

Thanks,
Kentaro.

5 REPLIES 5

-O-
Kilo Patron
Kilo Patron

You mean you want o update records retroactively with the first assignment information?

Hello, Thank you for replying.

It's exactly as you said.

 

Thanks,

Kentaro.

I suppose in that case what one needs is the HistoryWalker class. It enables looping through versions of an audited record as one would loop through records. So by revisiting each version (of each record) one can find the 1st record where Assigned to is not empty and fetch the sys_updated_on value.

E.g. if I run code

 

(function () {
	var incidentHW = new sn_hw.HistoryWalker('incident', '1c741bd70b2322007518478d83673af3');

	incidentHW.setFieldLevelSecurity(false);
	incidentHW.setRecordLevelSecurity(false);
	incidentHW.setWithChanges(false);
	incidentHW.setWithJournalFields(false);
	incidentHW.setWithVariables(false);

	while (incidentHW.walkForward()) {
		var incident = incidentHW.getWalkedRecordCopy();

		gs.debug(incident.sys_mod_count + '\t' + incident.sys_updated_on + '\t' + incident.assigned_to.getDisplayValue());
	}
})();

 

in Scripts - Background of my PDI, I get back:

 

[0:00:00.049] Script completed in scope global: scriptScript execution history and recovery available here

*** Script: [DEBUG] 0	2016-12-12 15:19:57	
*** Script: [DEBUG] 1	2016-12-12 16:30:49	Beth Anglin
*** Script: [DEBUG] 2	2016-12-12 17:01:24	Beth Anglin
*** Script: [DEBUG] 3	2016-12-12 17:57:00	Beth Anglin
*** Script: [DEBUG] 4	2016-12-12 18:52:42	Beth Anglin
*** Script: [DEBUG] 5	2016-12-12 20:43:50	Beth Anglin
*** Script: [DEBUG] 6	2016-12-12 21:26:36	Beth Anglin
*** Script: [DEBUG] 8	2016-12-13 00:56:57	David Loo
*** Script: [DEBUG] 9	2016-12-13 14:43:17	David Loo
*** Script: [DEBUG] 10	2016-12-13 15:53:01	David Loo
*** Script: [DEBUG] 11	2016-12-13 16:12:36	David Loo
*** Script: [DEBUG] 12	2016-12-13 18:42:25	David Loo
*** Script: [DEBUG] 13	2016-12-13 20:30:14	David Loo
*** Script: [DEBUG] 14	2016-12-13 21:43:14	David Loo
*** Script: [DEBUG] 15	2016-12-14 02:46:44	David Loo

 

As you can see this demo incident has been assigned on 2nd modification @ 2016-12-12 16:30:49 to Beth almost an hour after creation.

Here's the same in the Activity formatter on the Incident form:

2023-01-10-7.png

 

Thank you.

I just check it!

Thanks,

Kentaro.