Hid widget based on location

Suraj_18_18
Tera Contributor

Hi, I want to hide widget if logged in user country is germany. 
Can community will contribute in my post to complete this requiremet.

Thanks

1 ACCEPTED SOLUTION

Cheikh Ahmadou
Tera Guru

You can just activate  user criteria for Service Portal plugin and enable the system property to use user criteria for portal.
Then you will be able to apply user criteria to widget based on location.

View solution in original post

10 REPLIES 10

Mark Manders
Mega Patron

What kind of widget? You are in the AI Platform section, so that doesn't help in knowing if you are on the portal or creating dashboards or even at some other place of the platform. Without knowing what you exactly are doing, we can only guess and that gives way to many options.

One solution could be: use user criteria. But it could also be completely wrong, because your widget isn't connected to user criteria. So please provide more information.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@Suraj_18_18 

please share some screenshots for your question

what's your actual business requirement

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

i know there is nothing in HTML, it means can't we hide the widget basis on user location?

Suraj_18_18
Tera Contributor

@Ankur Bawiskar @Mark Manders 
its web chat widget [aavamo]

I wrote below code in server side

 

 data.showWidget = false; // Default: don't show
  var locationId = gs.getUser().getLocation();
 
    if (locationId) {
        var usrLocation = new GlideRecord('cmn_location');
        if (usrLocation.get(locationId)) {
            var userCountry = usrLocation.getValue('name'); // Make sure 'country' is populated
            
                data.country = userCountry; // Show widget
gs.log("suraj" +userCountry);
if (userCountry !== "TRD Gurugram") {
            data.showWidget = true;
     }
   }
 }

I am getting country in logs. but no idea how to hide that widget