Get the date on which the notification is sent and store the date in one of the field on the form

Pratiksha Lang1
Kilo Sage

I want to get the date on which the notification is sent and auto populate the same notification sent date in one of the custom field on the form. 

I have tried this with Business rule but it doesn't work.

 

PratikshaLang1_0-1695712389587.png

 

PratikshaLang1_1-1695712431335.png

 

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @Pratiksha Lang1 

Instead of document_id, shouldn't you be using instance field.

Change first line of code:

var ref = current.getValue("instance");

 

Feel free to mark apt response as Helpful and Correct so thread can be close, and makes it easier for others to spot the answer looking for similar issue. 

Help make community better!

Best Regards
Aman Kumar

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

Hi @Pratiksha Lang1 ,

you would require business rule on email logs[sys_email] table and then pick the time when the type changes to sent and populate the updated time in incident record field.

Condition should be such that it only works for incident table

BR: On sys_email

After Update:

Condition: Target table is incident AND Type is sent

Script:

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

	// Add your code here

	var inc = current.document_id;
	var gr = new GlideRecord('incident');
	gr.get(inc);
	gr.<field> = current.sys_updated_on; // give here the custom date time field
	gr.update();

})(current, previous);

SandeepDutta_0-1695713135293.png

 

SandeepDutta_1-1695713135345.png

 

 

I have already done the same thing @Community Alums 

Aman Kumar S
Kilo Patron

Hi @Pratiksha Lang1 

Instead of document_id, shouldn't you be using instance field.

Change first line of code:

var ref = current.getValue("instance");

 

Feel free to mark apt response as Helpful and Correct so thread can be close, and makes it easier for others to spot the answer looking for similar issue. 

Help make community better!

Best Regards
Aman Kumar

Thank You So Much for your help, this works @Aman Kumar S