- 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 09:52 AM
Hi
Apologies if the below is stating the obvious, but in case not...
1) I notice the script above only checks to see if the Opened_For changed. What happens if the Subject_Person changes, do you not also need to check for that? Or is this field locked once the Case is raised?
2) Additionally it might also be worth considering creating OnCellEdit scripts if the fields you're comparing can be changed in the list view.
3) Finally, obviously I no have idea about the HR rules of your company, but your requirement seems to imply that if the person in the Subject_Person field is not the same as the person in the Opened_For field they should not see the Case.
If my understanding is correct, you might need to consider what to do in the scenario where the user in the Subject_Person has a role that grants them access to HR Cases (i.e. they work in HR) and thus CAN see it even when you might not want them to.
Best,
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2023 09:35 AM
Hi Ankur, the property 'changed' is not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2023 05:23 AM