Recent searches


No recent searches

How can the custom field be used as a view column in the requirements.json file?



Posted May 07, 2023

Hello everyone!

I'm trying to add two custom fields defined in the requirements.json file to a custom view that is set in the same file by passing the ticket field property key. For instance:

{
  "ticket_fields": {
    "support_description": {
      "type": "text",
      "title": "Support description"
    },
    "number_of_issues": {
      "type": "integer",
    "title": "Number of issues"
    }
  },
  "views": {
  "view_tickets_updated": {
      "active": true,
      "conditions": {
        "all": [
          {
            "field": "status",
            "operator": "less_than",
          "value": "solved"
          },
          {
            "field": "assignee_id",
            "operator": "is",
            "value": "current_user"
          }
        ],
        "any": []
      },
      "default": false,
    "description": "Tickets updated",
      "output": {
      "columns": ["status", "requester", "number_of_issues", "support_description", "assignee"],
        "group_by": "assignee",
        "group_order": "desc",
        "sort_by": "status",
        "sort_order": "desc"
      },
    "title": "Tickets updated <12 Hours"
    }
  }
}

According to the documentation, this should be possible using dependent app requirements:

Some required resources, such as triggers or views, may depend on other resources in requirements.json. In these cases, use the resource's property key wherever the equivalent API payload would use the resource's id.

https://developer.zendesk.com/documentation/apps/app-developer-guide/apps_requirements/

However, in the documentation, we can find only a sample configuration with a reference for a custom target (an_email_target) by passing email target's property key when defining an action for the trigger.

 For example, the following requirements.json file declares an email target and a trigger. The trigger references the email target's property key.

{
  "targets": {
    "an_email_target": {
      "title": "A sample email Target",
      "type": "email_target",
      "email": "foo@bar.com",
      "subject": "Hello, from this target!"
    }
  },
  "triggers": {
    "email_on_ticket_solved": {
      "title": "Email on ticket solved Trigger",
      "all": [
        {
          "field": "status",
          "operator": "is",
          "value": "solved"
        }
      ],
      "actions": [
        {
          "field": "notification_target",
          "value": ["an_email_target", "Ticket {{ticket.id}} has been updated."]
        }
      ]
    }
  }
}

Can I use the same approach for columns when defining views and referencing custom fields using property keys? Thanks!


2

2

2 comments

image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Miro! The short answer is, no, this will not work. The reason for that is when you're creating a view and adding columns for custom ticket fields, you need the field id, not the name of the field. Since the requirements file is creating the fields, there is no way to get that id beforehand, and thus it wouldn't be possible to add them in the view's columns.

-1


Greg, that explanation doesn't follow. As Miroslaw pointed out, you can use the ticket fields, targets, and webhooks you're creating in many places in the requirements file: in the actions of triggers, automations, and macros, and in the conditions of triggers, automations, and even views. You use the key of the dependency being created. I've successfully used this extensively. But in views, adding the key of the new ticket field to the output property, and both Miroslaw and I would like to know why.

 

It cripples creating views in the requirements.json. If you want to display any of the custom data your app is creating in the view, you'll have to create the view after installing the app. Worse yet, if you ever have to uninstall and reinstall the app, you'll have to re-add those fields.

 

I hope this is something Zendesk is aware of and working on, hopefully along with allowing the creation of custom forms in the requirements file.

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post