how to make field mandatory when group name.manger,members added have changes

raj765_32
Tera Contributor

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:

 

(function executeRule(current, previous /*null when async*/) {

if(current.name.changes() || current.manager.changes() || current.sys_user_grmember.changes())

if(current.u_work_notes.isNil){

gs.addErrorMessage("Please fill data in worknotes field");
current.setAbortAction(true);
}

})(current, previous);
 
whenever changes are made for the above two fields record is getting saved but i dont want record to be saved unless worknotes field is filled and the above code is not working when group members are added or removed.
 
Please help me with this

 

2 ACCEPTED SOLUTIONS

SN_Learn
Kilo Patron
Kilo Patron

Hi @raj765_32 ,

 

Please try the below:

SN_Learn_0-1722229387632.png

 

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.

View solution in original post

Go with 3 checkbox as true, then it will also consider when you are removing user:

SN_Learn_0-1722235780863.png

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

21 REPLIES 21

after i enter any data in worknotes field users are not getting added

 

Hi @raj765_32 ,

 

Please remove the filter highlighted below:

SN_Learn_0-1722235157165.png

 

 

Now, it should work.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

after i remove this condition, previously it was showing 8 users and after i remove 3 users no error is thrown and group members are reflected to 5 and worknotes not been filled

As you are removing users now which means you are deleting. In your business rule you have ticked inserted/updated.

 

Try to add new users then you will receive the error message.

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.