- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 09:31 PM
Hi can anyone pls help me with scenario for,
when a field in group table
"Name"
"Manager"
"Group Members'
are updated. i have to make a field "Worknotes" mandatory in group table
i have written a before business rule with an update option and written the below code:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 10:03 PM
Hi @raj765_32 ,
Please try the below:
In Advance section:
(function executeRule(current, previous /*null when async*/ ) {
if (current.u_work_notes.isNil()) {
gs.addErrorMessage("Please fill data in worknotes field");
current.setAbortAction(true);
}
})(current, previous);
This will work for both the fields 'Name' and 'Manager' but not for Group members because that is not a field rather it is a separate table. So, we need to write a business rule on that table separately.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 11:49 PM
Go with 3 checkbox as true, then it will also consider when you are removing user:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 09:56 PM
Hi @raj765_32
why don't you prefer writing a "onChange" client Script.
You can also try UI Policy
Happy Learning
…………………………………………..
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 10:03 PM
Hi @raj765_32 ,
Please try the below:
In Advance section:
(function executeRule(current, previous /*null when async*/ ) {
if (current.u_work_notes.isNil()) {
gs.addErrorMessage("Please fill data in worknotes field");
current.setAbortAction(true);
}
})(current, previous);
This will work for both the fields 'Name' and 'Manager' but not for Group members because that is not a field rather it is a separate table. So, we need to write a business rule on that table separately.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 10:16 PM
Can you please send me code for group members also?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2024 10:26 PM
@raj765_32 , Try the below:
Business rule on [sys_user_grmember] table, before insert
Script:
(function executeRule(current, previous /*null when async*/ ) {
var grp = new GlideRecord('sys_user_group');
if (grp.get(current.group)) {
if (gs.nil(grp.u_work_notes)) {
gs.addErrorMessage("Please fill data in worknotes field");
current.setAbortAction(true);
}
}
})(current, previous);
Mark this as Helpful / Accept the Solution if this helps.