Auto populate Current Date time in a field?

naveenmyana
Giga Expert

Hello,

 

I have a requirement to autopopulate current date time a field when we click on a link in the notification, I am trying to generate the URL using below:

Click Here:  ${URI+&sysparm_begin=gs.nowDateTime()}   but this is just not giving me anything.

Any suggestions on how we can achieve this, Please share your thoughts on this one.

 

 

 

 

8 REPLIES 8

dvp
Mega Sage
Mega Sage

Try this and see if it works

 ${URI+&sysparm_begin=ONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()}

Hello,

 

I have tried your code still it is not setting any value in the field.

asifnoor
Kilo Patron

Hi,

Write a notification mail script like below and include that in your notification.

Name: printDateTime

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
var currDate =  gs.nowDateTime();
	template.print('<a href="' + gs.getProperty('glide.servlet.uri') + '&sysparm_begin='+currDate+'">' + 'Click Here111' + '</a>');
})(current, template, email, email_action, event);

Then in your notification, wherever you want that link, simply call like this

${mail_script:printDateTime} 

I checked in my dev instance and it is generating the link with the date and time correctly.

Mark the comment as a correct answer and also helpful once worked.

Hello Asif,

 

I have tried your code and I an getting the date time but it is not redirecting to correct page..once we click the link it should redirect to outage form and set the current date time in the field. Below is the result I got

 

find_real_file.png