- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 05:02 AM
HI,
I have a onsumit client script on a form, when a value of a field changes I need to check if the value is same as another field and if so, do a confirm popup.
Can someone help with this please.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:09 AM
Hi,
update as this
function onSubmit() {
var subjectPersonValue = g_form.getValue('subject_person');
var openedForValue = g_form.getValue('opened_for');
var openedFor = g_form.getControl('opened_for');
if(openedFor.changed){
if (subjectPersonValue == openedForValue) {
confirm("You have set the Opened For to the Subject Person, which will grant them access to view the Case - are you sure?");
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 06:13 AM
Hi,
you can use this to check if field got changed
function onSubmit(){
if(g_form.isUserModified('field_name')){
// check for value and show alert
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 06:55 AM
Hi, I used that but getting error
function onSubmit() {
var subjectPerson = g_form.getValue('subject_person');
var openedFor = g_form.getValue('opened_for');
if(g_form.isUserModified('opened_for')){
if (subjectPerson == openedFor) {
confirm("You have set the Opened For to the Subject Person, which will grant them access to view the Case - are you sure?");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:01 AM
Hi,
is the field name correct?
is the field opened_for present on the form?
g_form.isUserModified('field_name') should work on normal form view
possibly g_form.isUserModified('field_name') is not supported in portal
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:03 AM
hi
I am not using portal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 08:09 AM
Hi,
update as this
function onSubmit() {
var subjectPersonValue = g_form.getValue('subject_person');
var openedForValue = g_form.getValue('opened_for');
var openedFor = g_form.getControl('opened_for');
if(openedFor.changed){
if (subjectPersonValue == openedForValue) {
confirm("You have set the Opened For to the Subject Person, which will grant them access to view the Case - are you sure?");
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader