How to identify which button is clicked on the form using client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2009 12:37 PM
I have three Buttons on the form :
1. Hold
2. Cancel
3. Save Draft
How to identify which button is pressed on the form? On submit event in client script i want to know which button is pressed? If cancel or hold is pressed then want to make comments mandatory before submission.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2009 02:10 PM
Check out this article on our wiki.
http://wiki.service-now.com/index.php?title=Useful_Scripts#Make_close_note_mandatory_.28takes_into_account_the_close_button_being_clicked.29
Each UI action can be identified by its action name (if it has one) or by its sys_id. The script referenced above looks like it's a pretty close example for what you want to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2009 03:38 PM
Hi Mark,
Thanks for your reply.
But on the form I have two buttons using Action = sysverb_cancel. I'm doing this to avoid check for mandatory fields before calling current.update. In this case how can I find which button is clicked. is there a way to get "gsft_id" fr the button.. as its different for each button.
Amit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-12-2009 03:57 PM
You can use a DOM inspector to see if there's another way to reference the button. The easiest way is just to change the action name on one of your UI actions if you can so that the names aren't all the same.