- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 07:51 AM
Hi All,
We are in the process of adding a dashboard to our customer portal. This shows various reports about that customers incidents. When a portal user drills into the incident they get the self-service view of the form.
On our incident form we have both work notes and additional comments fields on the form. There is a tick box which alters which is displayed:
We have a system preference that sets this to worknotes - this is in place as a safe guard to try and prevent users accidentally adding a work note as an additional comment.
As portal users do not have visibility of work notes it is meaning that the user sees the 'post' button but there is no field to input the comment:
If I create as user preference for the portal user of glide.ui.incident.stream and set this to comments it then works and the portal user gets the field to add additional comments.
I don't want to have to add this user preference manually everytime we give a user access to the dashboard. We control this by adding the users to a specific group. Is there a way to get the user preference to auto generate when the user is added to the group?
Are there any other altrnatives
Thanks
Sam
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 07:40 AM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var preference = new GlideRecord ('sys_user_preference');
preference.addQuery('name','glide.ui.incident.stream_input');
preference.addQuery('user', current.user);
preference.query();
if (!preference.next()){
preference.name = 'glide.ui.incident.stream_input';
preference.vaule = 'comments';
preference.type = 'string';
preference.user = current.user;
preference.insert(); //since you said this was a before business fule you should not need this but I wanted to give it to you just in case.
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2018 08:04 AM
I would do a business rule on the sys_user_grmember that runs when a record is inserted and the group matches the one you are talking about. You can then script it to add a record into sys_user_preference table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 03:31 AM
Hi,
I've attempted to create a business rule, but I'm struggling to get this to work - still learning scripting.
currently have my business rule set as:
I've added 3 users to the group Customer portal - Report Users, but no preference has been set for these.
Can you point me in the right direction?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 03:45 AM
Hi,
I've noticed that I am updating my own preference rather than the user being added to the group,
What do I need to do to get the user being added to the group?
Thanks
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2018 04:03 AM
I've just re-tried but still not getting the user preference set:
(function executeRule(current, previous /*null when async*/) {
var userGR = new GlideRecord('sys_user');
if(userGR.get(current.getValue('user'))){
gs.log('username - ' + userGR);
userGR.setPreference("glide.ui.incident.stream_input", "comments");
}
})(current, previous);
in my logs I can see:
I've checked and the sys ID is the user I've added to the group