Module Filter base on User's country

Merza Lyn
Mega Guru

From this module Site Risks, visible only to users that have role: sn_risk.site_head, sn_risk.site_risk_manager

Link Type

MerzaLyn_0-1738826331348.png

 

The requirement is that when a user that a member of those roles open the Site Risks he or she can only see the lists of Risks record that Owner is same as his/her country.

 

Example
YuMi Kim has the role sn_risk.site_head and she is from MerzaLyn_2-1738826695294.png.

When she open/access Site Risks

MerzaLyn_3-1738826766386.png

She should only see Risks records that the Owner is from Korea, Republic of

MerzaLyn_4-1738826942794.png

 

 

3 REPLIES 3

Najmuddin Mohd
Mega Sage

Hello @Merza Lyn ,

You can add the role in Visibility 

NajmuddinMohd_0-1738841591429.png


And to filter records to show only the records to the location she belongs to is,

you can write a script include and call in the Filter.
You need to dot walk, from Owner > Location > Country || is || javascript: new getUserLocation();

The script include should return the users country.


If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

Hi @Najmuddin Mohd 

Can you help me with the script include?

maheshkhatal
Mega Sage

Hello @Merza Lyn ,

          Click on the Edit Icon of the module and in the Visibility section give the required role and in the filter section provide for Owner > Location > Country || is || javascript: new getUserLocation();

 

The Script include will look something like the below:

 

   var locationGr= new GlideRecord("sys_user");
   locationGr.addQuery('location_matching_criteria");
locationGr.query();
var userIDs=[];
while(locationGr.next()){}
  
     userIDs.push(locationGr.getValue('field_name'));
    }
   return 'sys_idIN'+userIDs;
  }

Mark this response as helpful.

Thank you.

Mahesh.