javascript:getMyGroups() not working in business rule

dhathri1
Giga Contributor

Hi All,

current.addQuery('assignment_group','javascript:getMyGroups()'); is not working, Please let me know what is exactly wrong in this.

14 REPLIES 14

In that case he will be able to see only the Incidents opened by/caller is him.But the user wants to see the incidents assigned to his grps as well


rob_pastore
ServiceNow Employee
ServiceNow Employee

I don't mean to add the code to that exact line, what I mean is the syntax of that line needs to be followed.



the if part is only dealing with end users, who do not have roles, so part you are adding would be for users with the itil rule (i am assuming otherwise they wouldn't be in assignment groups)



if (!gs.hasRole("itil") && !gs.hasRole("incident") && !gs.hasRole("field_services") && !gs.hasRole("problem") && !gs.hasRole("change") && !gs.hasRole("knowledge") && !gs.hasRole("release_v2_admin") && gs.isInteractive()) {


  var u = gs.getUserID();


  var qc = current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);


  gs.print("query restricted to user: " + u);


}   else {



//put your code here and make sure you add query is set to



var qc = current.addQuery('assignement_group','IN',gs.getMyGroups());




}


Basically user should be able to see all the incidents assigned to his groups as well as opened by/caller is him


rob_pastore
ServiceNow Employee
ServiceNow Employee

yes, this will do that.   If a user is assigned to a group, they will have at least one of the roles in your if statement (at least they should, that is the intent of this statement, to separate ess users from itil users)



So the first part of the if is used just to allow ess users to see only their tickets.



The else will filter for all itil users, to only allow them to see tickets that are assigned to their groups.


Anurag Tripathi
Mega Patron
Mega Patron

this will work




current.addQuery('assignment_group',getMyGroups());


-Anurag