How to modify Ticket Fields widget in Service Portal?

Priyanka Gupta
Mega Guru

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 -

Incident.PNG

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

11 REPLIES 11

cminarich
Kilo Expert

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.


Thank you for reply Chris! I will try your approach and get back to you asap.



Thanks,


Priyanka


hi priyanka,

 

did you manage to solve this?

how did you set the sys_id to be dynamic in the URL?

 

Thanks!

Hi Chris,



I have the similar issue and i.e., In ticket field widget all the fields showing only left side but i want to place side by side...How can i achieve this?? Refer the attached


document...



Screenshot (45).png