How to modify Ticket Fields widget in Service Portal?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 03:12 PM
Hi Community,
I have a situation where I need to modify the Ticket Fields widget to include a hyperlink to an Incident. Here's an image that explains what I am looking to achieve -
I want to make the Incident No (highlighted in the image with red) a hyperlink, so that when an itil user clicks on the Incident no, the user gets redirected to the incident.
Catch - This hyperlink should only appear for the itil user and rest of the users should see the widget as is.
I know Form widget is one way of showing the related Incident record on the same page but I have no way of limiting its visibility to itil users alone.
Any leads would be helpful.
Thank you,
Priyanka
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 03:40 PM
You will need to clone the OOB Ticket Fields widget and then modify it to fill your needs. You can create a boolean variable like data.is_link or something like that and do you checks and set the variable accordingly. From there you can do a check in your HTML using an ng-if and if field == 'number' && data.is_link make it a link otherwise just use the code as is.
So in your server script you will need to add:
data.is_link = gs.getUser().hasRole('itil');
Then in the HTML add in the red code:
<div ng-if="data.fields.length > 0">
<div class="row">
<div class="col-md-6 col-sm-12 col-xs-6 m-b break-word" ng-repeat="field in data.fields"
ng-if="field.value && (field.type != 'decimal' || field.type == 'decimal' && field.value != 0)" >
<label class="m-n">{{field.label}}</label>
<span ng-switch="field.type">
<div ng-switch-when="glide_date_time" title="{{field.display_value}}">
<sn-time-ago timestamp="::field.value" />
</div>
<div ng-switch-default >
<div ng-if="field.label == 'Number' && data.is_link">
<a href="<add link here>">{{field.display_value}}</a>
</div>
<div ng-if="field.label != 'Number' || !data.is_link">
{{field.display_value}}
</div>
</div>
</span>
</div>
</div>
</div>
Hoping this is at least enough to get you on the right path.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 04:07 PM
Thank you for reply Chris! I will try your approach and get back to you asap.
Thanks,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2019 06:35 AM
hi priyanka,
did you manage to solve this?
how did you set the sys_id to be dynamic in the URL?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-29-2017 02:54 AM