- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014 01:51 AM
Hi,
We need to restrict access on our ess portal to people who are members of one of three possible departments (not roles or groups) and admin users.
We've looked at doing this by adding a condition to the block - dynamic content, by checking the box "conditional" and displaying the condition script field.
Whatever we try it seems to block everyone regardless of department? We've tried simplifying it but still no joy
We've tried various versions along the lines of:
gs.getUser().getDepartmentID() == '40eda940ac5c81008f7cf71e9a30107f'
Any help appreciated - we are currently on the Berlin release.
thanks
Solved! Go to Solution.
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:21 AM
Hmm, I would think that would work if you removed the ( and made it a double == compare
but it did not work for me that way either, however I was able to create a variable using the glide record to grab the company name and use that to compare with, and you can use this method to grab any field off of the user record myvar = user.fieldname;
<g:evaluate>
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
mycompany = user.company;
</g:evaluate>
<j:if test="${mycompany=='company_sysid'}">
Add Your Company Text Here
</j:if>
but you may want also prefer to use the switch statement, if you have numerous companies , rather than lots of IF
<g:evaluate>
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
var mycompany = user.company;
</g:evaluate>
<j:switch on="${mycompany}" >
<j:case value="2d35a86ff4b381849c7dcf0aa470a547">
<br />Company 1 Name Text
</j:case>
<j:case value="2d35a76aa4b381849c7dcf0aa470a546">
<br />Company 2 Other Text
</j:case>
</j:switch>
and sorry; I do not know of any other way to do a global replace or change, other than having to edit of each page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 06:09 AM
Thanks a lot Robert. This is working however can you help with the code if we wanted to make it dependent on our user's company so instead of group name i.e.:
<j:if test="${gs.getUser().isMemberOf('GroupName')}">
it would be something like...
<j:if test="${gs.getUser().getCompanyID()=('5c6faa8389a249405f2c0203c80f605c')}">
This isn't working, I presume because I'm not saying whether if it's that ID to make it true or false?
Also, how can I apply a new dynamic block to all pages without manually editing every page?
Thanks again,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:21 AM
Hmm, I would think that would work if you removed the ( and made it a double == compare
but it did not work for me that way either, however I was able to create a variable using the glide record to grab the company name and use that to compare with, and you can use this method to grab any field off of the user record myvar = user.fieldname;
<g:evaluate>
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
mycompany = user.company;
</g:evaluate>
<j:if test="${mycompany=='company_sysid'}">
Add Your Company Text Here
</j:if>
but you may want also prefer to use the switch statement, if you have numerous companies , rather than lots of IF
<g:evaluate>
var user = new GlideRecord('sys_user');
user.get(gs.getUserID());
var mycompany = user.company;
</g:evaluate>
<j:switch on="${mycompany}" >
<j:case value="2d35a86ff4b381849c7dcf0aa470a547">
<br />Company 1 Name Text
</j:case>
<j:case value="2d35a76aa4b381849c7dcf0aa470a546">
<br />Company 2 Other Text
</j:case>
</j:switch>
and sorry; I do not know of any other way to do a global replace or change, other than having to edit of each page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:50 AM
Superb! This is exactly what I was after, had no idea about switch statements prior. Many thanks for your time and help Robert.