User variable GMT conversion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2017 09:56 AM
I collect a 'requested for' date/time on my REQ form. When I write the value to the TASK, it displays in GMT. I understand that using the calendar picker on the form stores the date/time in GMT, not the user timezone, but how can I get the variable output in a workflow to convert back to user time zone without having to do a bunch of flippy floppy gobbildy gookey... err, what seems like erroneous code for such an operation. I cannot find anywhere on google where there's a '<variable>.datetime' attribute in the same idea as a <variable>.name displays the literal name entered into the form field.
Here is my workflow script;
task.short_description = current.short_description + " for " + current.request.requested_for.name;
task.description = "Add Nxlog Agent to:"
+ "\nDevice Name: " + current.variable_pool.eh_machine_name.name
+ "\nOS Version: " + current.variable_pool.eh_machine_os_version
+ "\nMachine IP: " + current.variable_pool.eh_machine_ip
+ "\nServer Function: " + current.variable_pool.eh_ina_server_func
+ "\nContact Name: " + current.variable_pool.eh_ina_contact_name.name
+ "\nRequested Install Date: " + current.variable_pool.eh_ina_req_inst_date
+ "\nNotes: " + current.variable_pool.eh_ina_notes
+ "\nAdditional Contact Info: " + current.variable_pool.additional_info;
I am trying to get the current.variable_pool.eh_ina_req_inst_date to display in est, not gmt.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 06:35 AM
It may use full
getDateFromFormat(g_form.getValue('the_date_field'), g_user_date_format);
(g_user_date_format — predefined variable which gets user specific date format)
(getDateFromFormat — method which converts to the specified date format)
g_user_date_time_format — can also be used to get user's datetime format.
Helpful link - https://www.servicenowguru.com/scripting/client-scripts-scripting/client-side-dates-in-servicenow/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-13-2017 10:12 AM
Thank you Prasad!
We actually ended up deciding that due to the nature of the request, it wasn't really appropriate for the requester to enter a time, only a date, and the system doesn't modify the date. But I appreciate this response should I need to convert the date/time in the future.