User Criteria

Sakshi Lambat
Tera Contributor

I want to create a user criteria for the employee center Get Support widget where I want to set the different static contents and in that I want to apply the user criteria where I want to fetch the cmn_location.company so how should i proceed for it.

Please help.

 

Thanks,

Sakshi

2 REPLIES 2

Community Alums
Not applicable

Hi @Sakshi Lambat ,

If you're trying to restrict visibility of static content items (used in the Get Support widget) based on the user's location’s company (cmn_location.company), you'll need to create a User Criteria that dynamically evaluates this relationship

 

 

  • Go to User Criteria:

    • Navigate to User Criteria in the platform (Self-Service > User Criteria or Employee Center > User Criteria depending on your version).

  • Create a New User Criteria Record:

    • Give it a meaningful name like: Company based on Location.

  • Use a Scripted Condition:
    Since cmn_location.company is not directly on the sys_user table, we need to script the condition.

script example 

// Example: Show content only if user's location's company is ACME
(function() {
    if (!gs.hasRole('user')) {
        return false;
    }

    var userGR = new GlideRecord('sys_user');
    if (userGR.get(gs.getUserID())) {
        var location = userGR.location;
        if (location) {
            var locationGR = new GlideRecord('cmn_location');
            if (locationGR.get(location)) {
                if (locationGR.company.name == 'ACME') { // replace 'ACME' with your company name
                    return true;
                }
            }
        }
    }
    return false;
})();

 

Apply this User Criteria to the Static Content Item

 

SumanthDosapati
Mega Sage
Mega Sage

@Sakshi Lambat 

Do you want to apply user criteria to the each content inside the widget based on the company? or do you want to apply the user criteria for whole widget based on company?

 

Regards,

Sumanth