Issues with Hided External Content Catalog Item

Walter Toney
Tera Expert

Team,

 

I have been tasked with building a content item and have it restricted to non contractors. so fareverything is working on the item it shows up on the portal and when clicked it goes where we want it to go. the issue i'm having is the Not Available for item is NOT hiding it on the portal if the user is a contractor. can you look at my code and tell me what im doing wrong please.

 

var userCheck = new GlideRecord("sys_user");
userCheck.addQuery("sys_id", gs.getUserID());
userCheck.query();
if (userCheck.next()) {
    if (userCheck.email.indexOf('@CTR.WinstarInc.com') > -1)
        answer = true;
    else
        answer = false;
}

 

basically i want to hide it on the portal if the users emails address have CTR in it.. that is how we identify contractors

2 REPLIES 2

ShubhamGarg
Kilo Sage

Hello @Walter Toney ,

 

I would like to suggest a different, safe and efficient approach to this problem statement -

  1. Create a contract group and add all contractor to it.
  2. You can also assign a role to this group and this group membership can be dynamically used across ACLs, QBRs and catalog items to maintain security. It will reduce re-work and re-scripting.

Specific to your code -

Can you try using while loop instead of if loop? Print the logs.

Mark this as Accepted Solution/Helpful if above info. helps in any way and help in closing this thread.

Regards,
Shubham

Walter Toney
Tera Expert

we are talking 1000's of people The email address is assigned and is readonly so it can't change so the group and Role would not be efficient