- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 09:26 AM
hi guyz...
plz help me
i dont want to show the users comments to the other users but they are able give their own comments for knowledge article portal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2017 06:40 AM
Hello m deepu,
1) The portal should primarily be for end users. Admin and knowledge users will still have access to comments on the back end regardless.
2) If you do decide that you want these users to be able to see comments in the portal regardless you will have to replace the commented out lines with a new div that shows / hides conditionally. Your new ng-if is going to be paired with whatever data you want from the server. You can use the below link, and have access to the entire users record to determine the condition.
http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0
In my first example I allowed only the Finance department to see the comments putting the logic into the ng-if. And in the second example allowed only admin and change managers to see the comments keeping the logic in the server script.
Department:
Roles:
Using a combination of the server script and ng-if condition, you can get the boolean you need to conditionally show or hide the comments.
text of the needed lines:
HTML:
<div ng-if="data.hasRole">
...
</div>
Server script:
var myUserObject = gs.getUser();
data.hasRole = (myUserObject.hasRole('admin') || myUserObject.hasRole('change_manager'));
Or :
<div ng-if="data.dept == '{sys_id of dept here}'">
...
</div>
var myUserObject = gs.getUser();
data.dept = myUserObject.getDepartmentID();
Best,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:35 PM
Hello m deepu,
Unfortunately the comments are baked into the widget. You can edit the instance options, but if you select not to show user comments it removes the ability for the users to add comments as well. You would have to clone the widget, I created a custom widget called kb article hide comments.
Luckily, all the comment html is at the bottom and lumped together.
While you could change the client / server script to not pull the data, the simplest / quickest way to achieve what you are looking for is just to not show it, which involves 7 new characters to your widgets HTML!
Please let me know if you have any questions!
Best,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2017 12:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2017 02:16 AM
thank you andrew,
one more thing, is there any way to show those comments for admins.and for some roles??
i mean end users not able to see the feedback comments....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2017 06:40 AM
Hello m deepu,
1) The portal should primarily be for end users. Admin and knowledge users will still have access to comments on the back end regardless.
2) If you do decide that you want these users to be able to see comments in the portal regardless you will have to replace the commented out lines with a new div that shows / hides conditionally. Your new ng-if is going to be paired with whatever data you want from the server. You can use the below link, and have access to the entire users record to determine the condition.
http://wiki.servicenow.com/index.php?title=Getting_a_User_Object#gsc.tab=0
In my first example I allowed only the Finance department to see the comments putting the logic into the ng-if. And in the second example allowed only admin and change managers to see the comments keeping the logic in the server script.
Department:
Roles:
Using a combination of the server script and ng-if condition, you can get the boolean you need to conditionally show or hide the comments.
text of the needed lines:
HTML:
<div ng-if="data.hasRole">
...
</div>
Server script:
var myUserObject = gs.getUser();
data.hasRole = (myUserObject.hasRole('admin') || myUserObject.hasRole('change_manager'));
Or :
<div ng-if="data.dept == '{sys_id of dept here}'">
...
</div>
var myUserObject = gs.getUser();
data.dept = myUserObject.getDepartmentID();
Best,
Andrew