- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:17 AM
Hi there,
we have a ui action with following script:
function par_req() {
var gm = new GlideModal("glide_prompt", true, 1600);
gm.setTitle("Create Product Allocation Requests");
gm.setPreference("title", "Number of Allocations Required (Max 50)");
gm.setPreference("onPromptComplete", function(value) {
g_form.setValue('number_of_product_request', value);
g_form.save();
gsftSubmit(null, g_form.getFormElement(), 'add_product_allocation_requests');
});
gm.render();
}
when user clicks on it, it will show like below:
Ideally we are setting the value in a field, That field is of type integer. But If user enters alphabets, we have to show error.
For ex, if user enters 4a, I have to show error saying the please enter only number. Also if user tries to submit, do not let them submit it.
Is there any way I can perform the validation in UI action? Any references.
Please let me know. Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:34 AM
Hi @Naga Ravindra R ,
Can you try this
function par_req() {
var gm = new GlideModal("glide_prompt", true, 1600);
gm.setTitle("Create Product Allocation Requests");
gm.setPreference("title", "Number of Allocations Required (Max 50)");
gm.setPreference("onPromptComplete", function(value) {
if (!isNaN(value)) {
var intValue = parseInt(value, 10);
if (intValue >= 1 && intValue <= 50) {
g_form.setValue('number_of_product_request', intValue);
g_form.save();
gsftSubmit(null, g_form.getFormElement(), 'add_product_allocation_requests');
} else {
alert("Please enter a number between 1 and 50.");
}
} else {
alert("Please enter only numeric values.");
}
});
gm.render();
}
Please mark as Accepted as Solution !!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:25 AM
Follow thread it will be helpful:-
https://www.servicenow.com/community/developer-forum/using-ui-action-with-glidemodal/m-p/2348354
https://davidmac.pro/posts/2022-02-08-glidemodal/
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:34 AM
Hi @Naga Ravindra R ,
Can you try this
function par_req() {
var gm = new GlideModal("glide_prompt", true, 1600);
gm.setTitle("Create Product Allocation Requests");
gm.setPreference("title", "Number of Allocations Required (Max 50)");
gm.setPreference("onPromptComplete", function(value) {
if (!isNaN(value)) {
var intValue = parseInt(value, 10);
if (intValue >= 1 && intValue <= 50) {
g_form.setValue('number_of_product_request', intValue);
g_form.save();
gsftSubmit(null, g_form.getFormElement(), 'add_product_allocation_requests');
} else {
alert("Please enter a number between 1 and 50.");
}
} else {
alert("Please enter only numeric values.");
}
});
gm.render();
}
Please mark as Accepted as Solution !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 05:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 08:13 AM
Hi @Naga Ravindra R ,
If thats not works somehow, GlidaModal is not supported those capabilities. Instead you can go for an UI page for the same.
BR, Sohiht