- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 09:32 AM
What we are trying to do is hide the u_internal_external field from external users. This script seems to work but the problem is that users who are internal are not seeing the field. Initially I though there was code error. The ! implies that user who does not have the snc_external role then hide the field. I removed the ! because doing so implies that the user who has the external role should not see the field. When doing this and testing with an internal user the internal user sees the field. However, a user with the snc_external role is also seeing the field. What is the problem?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:33 AM
Our developer seems to have figured this out. Looks like a GlideAjax script is needed. To be honest I don't really follow the script so if anyone would like to attempt to explain it I would appreciate it.
function onLoad() {
//Type appropriate comment here, and begin script below
var aj = new GlideAjax('GetInternalExternalCSM');
aj.addParam('sysparm_name','getExternal1');
aj.getXMLAnswer(fun);
//Type appropriate comment here, and begin script below
function fun(answer)
{
var obj = JSON.parse(answer);
if(obj.internal == true)
{
g_form.setReadOnly('u_internal_external',false);
g_form.setMandatory('u_internal_external',true);
}
else if(obj.external == true)
{
g_form.setVisible('u_internal_external',false);
}}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:17 AM
Try this
| if(g_user.hasRole('snc_external')) | |
| g_form.setDisplay('u_internal_external', true); |
if(g_user.hasRole('snc_internal'))
| g_form.setDisplay('u_internal_external', false); |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:17 AM
Right, I think it's working OK for the internal user you're testing with. I'd like to know if the external user you're testing with indeed has the 'snc_external' role, since our .hasRole() is saying otherwise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:00 AM
We can first confirm if the role is being read correctly and then move onto other areas like UI Polices.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:02 AM
Great, was hoping there was some logging or debug mode. How can I accomplish that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 10:05 AM
I think for the internal users will have an snc_internal role. Can you update your script and include snc_internal role check for internal and snc_external for external users
