- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:17 AM - edited 04-21-2023 01:23 AM
Hi,
I have a Ui action on the alm_hardware table. When this button is clicked, a Modal UI Page appear with some validation to do.
I have 3 buttons :
Button 1 : Validate and do nothing (just a checkbox that will be unchecked and state that change).
Button 2 : Validate and update the asset (some fields are updated and some other actions).
button 3 : cancel (close the modal).
I know that when you have 2 buttons you can call the server side actions in UI action with gsftSubmit(null, g_form.getFormElement(), 'update');
But how you can distinguish that the user has clicked on the button 1 or button 2 from server side and then do nothing or update ?
Regards,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 11:46 PM
why not put the code of UI action in ui page itself?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 03:32 AM
all those buttons will be on UI page, have unique HTML ids for those and you can determine which one was clicked
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 04:43 AM - edited 04-21-2023 04:54 AM
Hi Ankur,
I have these 3 buttons on the UI Page :
UI PAGE HTML
<div class="row">
<div class="col-sm-4">
<button class="topIconEffect1 zoom-on shadow top_icon" id="cancel_button" onclick="return onCancel()" type="submit">
<h2>Annuler</h2>
</button>
</div>
<div class="col-sm-4">
<button class="topIconEffect2 zoom-on shadow top_icon" id="ok_button" onclick="return dontUpdate()" type="submit">
<h2>Valider l'affectation sans mettre à jour l'asset</h2>
</button>
</div>
<div class="col-sm-4">
<button class="topIconEffect3 zoom-on shadow top_icon" id="erase_button" onclick="return Update()" type="submit">
<h2>Update</h2>
</button>
</div>
</div>
UI PAGE CLIENT SCRIPT
function update() {
gsftSubmit(null, g_form.getFormElement(), 'Update'); // Server side of UI Action
}
function dontUpdate(){
removecheckBox();
}
function onCancel() {
closeGlideModal(); // if cancel, close modal box
}
The removeCheckBox() is a function on the Client side of the UI Action
My Question is how i can write condition server side if button 1 or button 2 have been clicked.
UI ACTION SERVER SIDE SCRIPT
If button Update clicked
Do this
and this on the asset form
If button dontUpdate clicked
Do that
and Do that on the asset form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2023 11:46 PM
why not put the code of UI action in ui page itself?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2023 12:04 AM
Hi Ankur,
You are right. I don't know why i was trying to come back to the UI Action.
I did it from the UI Page directly.
Thanks!