login user has role "AB" can resolve the incident

nani1
Tera Contributor

Hi All,

Seniors: if login user has a role "AB" have access to resolve the p1/p2 incidents.

i used BR - "Before Update"  to get it done how ever its failing. any mistake in my script?

(function executeRule(current, previous /null when async/) {
if (current. role != 'AB')
{ if (current.state == '6')
{ current.state = previous.state; // Rollback state change current.setAbortAction(true); gs.addErrorMessage('AB Role user can resolve the incident');
} }
})(current, previous);

 

2 REPLIES 2

SANDEEP28
Mega Sage

@nani1 You can configure business rule as below. Try to use condition builder as much as possible.

 

SANDEEP28_0-1712125398039.png

 

SANDEEP28_2-1712125688964.png

 

 

 

 

 

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

	if (!gs.hasRole('AB'))
	{
                current.setAbortAction(true);
		gs.addErrorMessage('only AB Role user can resolve the incident');
	}

})(current, previous);

 

 

 If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

Harish KM
Kilo Patron
Kilo Patron

Hi @nani1 there are errors in your BR. to check roles you need to use gs.hasRole() method

and for state check you can add the condition in Business Rule

 

if (!gs.hasRole('AB'))
{
current.state = previous.state; // Rollback state change
current.setAbortAction(true);
gs.addErrorMessage('AB Role user can resolve the incident');

}

 

Regards
Harish