Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to show /Hide 'Request something 'in Portal

Supriya25
Tera Guru

Hi All,


Servicenow Portal 'Request something' should be aviabale if logged in ITIL user is belongs to Claims Group and  when one Specific system property is TRUE .

if Person not belongs to Claims group , for them it should be available  as regular like others . no limitations show always .

please let me know if it is possible ?

Supriya25_0-1789993009913.png






6 REPLIES 6

Ankur Bawiskar
Tera Patron

@Supriya25 

create user criteria for this with script and add that in "Available For" related list for that catalog item

what's the issue faced?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

very wired thing is , from same Group , I have selected 4 peoples 
I flipped property value True to False vice versa . making changes in system property and If I impersonated with same person again and again result not changing as per system property

Property :
1.FALSE :
impersonated with user AAA : catalog item restricted and got info message also (Success)
2.TRUE :
Impersonated with. same user AAA: Catalog item still restricted 
But immediately I Impersonated with BBB user, catalog item is appearing .

I did property change again 
FALSE again : 
immediately I Impersonated with BBB user, catalog item is disappearing .(GOOD)
TRUE : 
immediately I Impersonated with BBB user, catalog item still disappearing .



WHY like this ? any suggestions please 
User 
Criteria 

gs.addInfoMessage("Result : "+new VisibilityCondition().userCriteria(user_id)); 
var vc = new VisibilityCondition(); 
answer = vc.userCriteria(user_id);


Script Include

 
userCriteria: function(userID) {
    // 1. Fail early if no userID is provided
    if (!userID) {
        return false;
    }

    // 2. Fetch system configuration property
    var isLoggingEnabled = gs.getProperty('trunOn_Off') === 'true';
    if (!isLoggingEnabled) {
        return false;
    }

    // 3. Define target roles
    var Roles = [
        'issues_user', 
        'wealth_user', 
        'tracker_user'
    ];

    // 4. Perform an efficient check using GlideRecord
    var userRoleGR = new GlideRecord('sys_user_has_role');
    userRoleGR.addQuery('user', userID);
    userRoleGR.addQuery('role.name', 'IN', Roles.join(','));
    userRoleGR.setLimit(1);
    userRoleGR.query();

    // Returns true if a record exists, false otherwise
    return userRoleGR.hasNext();
},

@Supriya25 

see response from @Aditya_hublikar 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks @Ankur Bawiskar . Kindly help me on below thing.

Regarding  user criteria ,

Google search is saying  if I take  Group, roles and Script. System will always consider SCRIPT and ignores Group, Roles and other fields completely ?

it misconception or it's fact . 

Supriya25_0-1790002463367.png