- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:24 AM
My Goal:
User has button they can click to change a task's status to In Progress and the task's Start Date/Time field to the current time.
The first part has been easy to script, but my mind is exploding with how difficult the 2nd part has been. I have to be missing something easy.
My current UI Action script:
function startActivity() {
g_form.setValue('u_status','1');
g_form.setValue('u_start_date_time',gs.now());
gsftSubmit(gel('sysverb_update_and_stay'));
}
Right now, it only updates the Status field. I've tried sooo many different things. What am I missing to make that Start Date/Time simply equal the current time at the time of saving?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:31 AM
Edit : use a server side button ....
current.u_status='1';
current.u_start_date_time=gs.now();
current.update();
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:28 AM
gs.now() is actually server side code, so it wont work inside the client side function of your UI action. you need to use
current.u_stat_date_time=gs.now();
at server side to set the value. If you want to do it from client side, you can refer this wiki link:-
Set Current DateTime In Field - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:31 AM
Edit : use a server side button ....
current.u_status='1';
current.u_start_date_time=gs.now();
current.update();
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:36 AM
Plus , if you want to do some client + server side processing using the same button , this would help
http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2014 05:37 AM
This was unbelievably easy - thank you.