Including validation within an if and obtaining the group name to generate an alert message

Igor Corr_a
Tera Expert

Hello,

I am creating a Business Rule to block the use of the "Copy partial project" and "Copy project" options via the planning console.

Despite already having an ACL that controls the creation of new projects, the options are still available within the planning console and I chose not to change the Angular that makes these buttons available.

The most viable option would be the creation of a BR.

Scenario: Only members of a certain group can create new projects.

With the current implementation of BR, users who do not belong to this group receive the access denied message when proceeding with the creation of the new project, however, I would like to improve this feedback.

Currently, my Business Rule is implemented like this:

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

var check = gs.getUser().getUserByID(current.sys_id).isMemberOf(gs.getProperty('nomeOfMyPropertyContainingSysIDOfMyGroup'));

if(check == 1){
gs.addErrorMessage(gs.getMessage("Group members only") + " " + ("Here I would like to include the name of my group") + " " + ("you can copy projects"));
current.setAbortAction(true);
}

})(current, previous);

Part 1: I believe that my if is not being executed because the access denied message continues to appear and not my personalized message.

Part 2: How to get the name of my group within the alert message informing the sys_id because eventually the group name may change and I would not like to leave the name recorded in the code.

Best Regards,

7 REPLIES 7

Sandeep,

This is the message.

 

 

This message might be coming due to an ACL issue. Please check if your user has the right permission.

Blocking is happening when the user does not belong to the group specified in the BR. This is the expected behavior.

During the tests shown in the printout, the user belonged to a group other than the one specified in the BR.

I also have an ACL that controls this permission.

By including the user in the group in question, it is possible to create the project.

It seems to me that the blocking is being carried out, however, the message is not being "read" from the BR, but rather, some standard message from the planning console screen when, when saving, the user does not have permission to create it.