- 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
01-19-2014 08:39 PM
Try this in your conditional statement, it worked on my system (except with a different sys_id)
checkDepartment();
function checkDepartment() {
if (gs.getUser().getDepartmentID() == '40eda940ac5c81008f7cf71e9a30107f') {
answer = true;
}
else {
answer = false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2014 12:26 AM
Absolute star! Thank you - it worked a treat! Happy bunnies all round...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 07:59 AM
Hi Mike,
We would like to do something similar whereby our ESS page footer is different so that depending on the user's company the relevant help desk number appears (i.e. we will have multiple footers).
I have used your script and modified it to include 'Company' instead however I have noticed that when unchecking Active on the original standalone footer we had, it is still showing on all pages and I don't understand why?
The footer block type is 'Static content'.
Any help much appreciated.
Cheers,
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2014 01:43 PM
We've made our footer a dynamic content block, and have differences based on group and\or roles
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Common Footer Code Would Go Here, i.e. you could just copy/past your static HTML code here
<j:if test="${gs.getUser().isMemberOf('GroupName')}">
add some additional "static" footer code here for this group
</j:if>
<j:if test="${gs.hasRole('admin')}">
add some more "static" content if this user has a particular role in the organization
</j:if>
</j:jelly>