February 16, 2025

List Assigned Assets in a Ticket Note

Colin Moore
List Assigned Assets in a Ticket Note

Have you ever wanted to list a users assigned assets from their profile into a ticket note? well then this liquid filter should help you out. The steps are quite simple in a workflow:

  • Get the User Assets via Web API: https://<tenant>.freshservice.com/api/v2/assets?filter="user_id:{{ticket.actual_requester.id}}
  • Parse the Header (this contains the asset count, no point listing the assets if the user doesn't have any assigned
  • Add condition logic based on P1.root.X-search-Results-Count not 0
  • Parse the Body (this contains the list of the assets)
  • Add the following test into a Note Action:
{% assign name_array = P4.root.assets.assets_object.name | remove: '[' | remove: ']' | remove: '"' | split: ',' %}
{% assign tags_array = P4.root.assets.assets_object.asset_tag | remove: '[' | remove: ']' | remove: '"' | split: ',' %}

{% for a in name_array %}
  {{ a }} : {{ tags_array[forloop.index0] }}
  
{% endfor %}

There you have it, a list of Assets in a note attached to a ticket. With this you can get inventive and perform more advanced operations, for example: determine if the user is requesting a change to an asset they are an owner.

Author:
Colin Moore