Service Portal form view for user without role

shuguang2
Kilo Expert

Hi, I have created a Service Portal view for Incident in order to show an specific UI action on the Service Portal. I have selected Service Portal View for the Form Widget. However this works only for users with a role. For users without role, still the ess view is shown. Any suggestion how to achieve this. Thanks in advance

5 REPLIES 5

CharlesGriff
Mega Sage

Hi Shuguang



I have done something similar on a client service portal and what we ended up doing is creating groups with users who you want to be able to see these incidents   and then creating an ACL to allow read permissions for those specific groups, remember that Service-Now restricts the incident to either the ITIL role or the person who logged the incident or anyone on the watch list.


The ACL script looks something like this.



gs.getUser().isMemberOf("group1") || gs.getUser().isMemberOf("group2");



Then the second step would be to edit the incident query business rule that would apply this permission. We used a before query business rule and it looks like this.



if (!(gs.hasRole("itil") || gs.getUser().isMemberOf("group")) && gs.isInteractive()) {


var u = gs.getUserID();


var c = gs.getUser().getCompanyID();


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


if (gs.getUser().isMemberOf("group")) {


qc.addOrCondition("company", c);


}



}


Thanks for your suggestions. In my case it is not an option to put all users without a role in a group. But I find another way to achieve what I need.


Jaspal Singh
Mega Patron
Mega Patron

Hi Shuguang,



Link Custom view for end user in Service portal should help.


I have now changed the Global Business Rule "Incident Functions" as following



// populate the default value for the caller
function incidentGetViewName() {
  if (gs.hasRole("itil"))
        return;
  if (view.startsWith("ess"))
        return;
  if (view == "sys_ref_list")
        return;
  if (view == "sp") //Service Portal View
        return;


  answer = "ess";
}



This allows User without a role to be able to use Service Portal View.



This Business Rule is already very old. Hopefully ServiceNow will make updates on this and provide user without role more View possibilities. This is especially need on the Service Portal, not least because there are limitation what can be show to user on the Service Portal (for example Client UI Action)