
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 07:41 AM
Hi,
Apologies if this is a simple question, but I'm fairly new to ServiceNow UI development.
I have a table in my scoped application, that looks like this:
When the user selects save or clicks one of the update buttons I need to display a message, along with an OK / Cancel button.
If they click OK, the record is saved/updated as normal, if they Cancel the record is not saved/updated.
What's the easiest way to achieve this?
Thanks,
Tim.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 07:51 AM
Hello Tim,
You can create an onSubmit Client script with the following code:
function onSubmit() {
var answer = confirm("Do you want to save the record? Press OK to save, Cancel to abort!");
if (!answer)
return false;
}
Please mark my answer as correct and helpful if it is relevant for you!
Thanks,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 07:51 AM
Hello Tim,
You can create an onSubmit Client script with the following code:
function onSubmit() {
var answer = confirm("Do you want to save the record? Press OK to save, Cancel to abort!");
if (!answer)
return false;
}
Please mark my answer as correct and helpful if it is relevant for you!
Thanks,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 08:06 AM
Thanks Filipe!
I would like to display different text for some of the buttons. Am I able to find out which operation/button has been clicked within the onSubmit() function?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 08:32 AM
Hello Tim,
The "Ok" and "Cancel" cannot be changed when using the "confirm" statement.
If you want to have something different there, you need to build up a UI page with custom buttons, each with a different label.
Please mark my answer as correct and helpful if it is relevant for you!
Thanks,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 08:51 AM
Hi Filipe,
Sorry, I didn't word that very well!
I have several buttons on the form, all of which fire the onSubmit() event, can I tell which one has been clicked and display a different confirm message for some of them?
Thanks (again!)
Tim.