The CreatorCon Call for Content is officially open! Get started here.

Advanced View Rule - hasRole + assignment_group

andreas_holgers
Kilo Expert

Hi,

I'm trying to achieve an view rule that accomplishes the following demand:

  • (gs.hasRole('real_estate_agent') && current.assignment_group == 'Real Estate'){
    answer = "real_estate";}

Tickets(sc_request) that are assigned to the Real Estate assignment group and their agents should have their own view.

Is this possible to accomplish? (I know that the use of current doesn't work in view rules)

Best Regards.
Andreas

 

1 ACCEPTED SOLUTION

Dubz
Mega Sage

Try this, i'm using something similar elsewhere to reference fields on the current form to set the view:

(function overrideView(view, is_list) {

var url = gs.action.getGlideURI().getMap();
var sysId = url.get('sys_id');

var gr = new GlideRecord('sc_request');

if (gr.get(sysId)) {

if(gs.hasRole('real_estate_agent') && gr.assignment_group.getDisplayValue() == 'Real Estate'){

answer = 'real_estate';
}
}


})(view, is_list);

 

View solution in original post

7 REPLIES 7

Hi David!

Thanks for your help.

Now I have the same problem for the sc_req_item table. I tried with your solution, just changing the GlideRecord to "sc_req_item". But no luck, any good ideas?

/Andreas

Hi Andreas,

The rule should work on any table, did you change the table that the view rule is set up against?

find_real_file.png

 

Hi,

Yes i did. It looks like this

find_real_file.png