- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 02:03 AM
Hi,
I have a field called start time of incident that field type is date and time so I need to show a field message and mentioning the time zone in which user has to enter the time and it should be based on logged user time zone.
For example:
If I have time zone set in my profile as IST. The message should be "please enter the time in IST time zone".
If I have time zone set in my profile as EST, the message should be "please enter the time in EST time zone".
Can you please help on this. It will be useful.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 03:12 AM
try this script include. It should work in scoped apps also:
var getUserTimeZone = Class.create();
getUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserTimeZone: function() {
var session = gs.getSession();
var zoneName = session.getTimeZoneName();
return zoneName;
},
type: 'getUserTimeZone'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 02:28 AM - edited 04-04-2024 02:55 AM
Hi, @mania
You could achieve this using onLoad Client Script and GlideAjax call:
function onLoad() {
var userTimeZone = new GlideAjax('getUserTimeZone');
userTimeZone.addParam('sysparm_name', 'getUserTimeZone');
userTimeZone.getXMLAnswer(answerParse1);
function answerParse1(response) {
var answer = "Please enter the time in " + response + " time zone";
g_form.showFieldMsg('due_date', answer);
}
}
Script Include:
var getUserTimeZone = Class.create();
getUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserTimeZone: function() {
var myUserObject = gs.getUser();
return myUserObject.getTZ();
},
type: 'getUserTimeZone'
});
Result:
I hope this information is useful to you! If you have any further questions or need clarification on any point, feel free to ask.
Best regards,
kkrushkov
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 02:48 AM - edited 04-04-2024 02:49 AM
Thanks for your responding!
I have tried which you are provided code but I am getting like the below screen short not taking time zone but my system time zone is US Central.
Can you help me.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 03:12 AM
try this script include. It should work in scoped apps also:
var getUserTimeZone = Class.create();
getUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserTimeZone: function() {
var session = gs.getSession();
var zoneName = session.getTimeZoneName();
return zoneName;
},
type: 'getUserTimeZone'
});