Auto populate Current Date time in a field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2019 11:30 AM
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.
- Labels:
-
Notifications

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2019 01:20 PM
If you look at my script, it is generating the link based on this property
gs.getProperty('glide.servlet.uri')
In place of this, you replace with your URL correctly, then it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2019 01:47 PM
I have used the below code and I am able to redirect to the correct page, but still it is not setting any value in the field:
template.print('<a href="' + gs.generateURL(current.getTableName(),current.sys_id) + '&sysparm_begin='+currDate+'">' + 'Click Here111' + '</a>');
Any suggestions here what is going wrong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2019 02:03 PM
Hello Asif,
I have got lucky this time and it is working fine now along with above mail script I have also written a client script below one to capture the parameters passing from notification and setting the value in field.
here is my script:
function onLoad() {
//Type appropriate comment here, and begin script below
var begin1 = getParmVal('sysparm_begin');
var end1 = getParmVal('sysparm_end');
if(begin1){
g_form.setValue('begin',begin1);
}
if(end1){
g_form.setValue('end',end1);
}
}
function getParmVal(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2019 10:58 PM
Can you add alert statement and check if you are able to fetch the value or not.
function onLoad() {
//Type appropriate comment here, and begin script below
var begin1 = getParmVal('sysparm_begin');
var end1 = getParmVal('sysparm_end');
alert(begin1);
alert(end1);
if(begin1){
g_form.setValue('begin',begin1);
}
if(end1){
g_form.setValue('end',end1);
}
}