{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/comments/213157847","pull_request_review_id":149931484,"id":213157847,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzE1Nzg0Nw==","diff_hunk":"@@ -669,19 +675,39 @@ var App = {\n   },\n \n   ccs: function () {\n-    return this && this.ticket && this.ticket.collaborators && this.ticket.collaborators.map(cc => cc.email)\n+    return this.ticket.collaborators && this.ticket.collaborators.map(cc => cc.email)\n   },\n \n   hideAncestryField: function () {\n-    if (this.settings.ancestry_field) {\n-      this.zafClient.invoke(`ticketFields:custom_field_${this.settings.ancestry_field}.hide`)\n-    }\n+    // Multiple cases:\n+    // - V1 app was installed before V2 migration:  settings and requirements fields exist\n+    // - App directly installed as V2: only requirements field exists\n+    // - Multiple forms are possible, fields can be added or removed from each form\n+\n+    return this.ajax('fetchTicketForms').then((data) => {\n+      data.ticket_forms.forEach((ticketForm) => {\n+        let fieldIds = ticketForm.ticket_field_ids\n+\n+        if (this.settings.ancestry_field) {\n+          let ancestryFieldId = this.settings.ancestry_field\n+          if (fieldIds.includes(parseInt(ancestryFieldId, 10))) {\n+            this.zafClient.invoke(`ticketFields:custom_field_${ancestryFieldId}.hide`)\n+          } else {\n+            this.zafClient.invoke('notify', `The form \"${ticketForm.display_name}\" should contain linked data setting field with ID \"${ancestryFieldId}\"`, 'alert', {sticky: true})\n+          }\n+        }\n \n-    // Hide requirements field. It should always be present whenever the V2 app is installed.\n-    return this.zafClient.get('requirement:linked_data').then((fieldData) => {\n-      if (fieldData['requirement:linked_data']) {\n-        this.zafClient.invoke(`ticketFields:custom_field_${fieldData['requirement:linked_data'].requirement_id}.hide`)\n-      }\n+        this.zafClient.get('requirement:linked_data').then((data) => {\n+          if (data['requirement:linked_data']) {","path":"src/javascript/app.js","position":70,"original_position":70,"commit_id":"9f2041b40ca1ce33504bdb0593a122fa5e1f3a7d","original_commit_id":"9f2041b40ca1ce33504bdb0593a122fa5e1f3a7d","user":{"login":"ocke","id":5171412,"node_id":"MDQ6VXNlcjUxNzE0MTI=","avatar_url":"https://avatars2.githubusercontent.com/u/5171412?v=4","gravatar_id":"","url":"https://api.github.com/users/ocke","html_url":"https://github.com/ocke","followers_url":"https://api.github.com/users/ocke/followers","following_url":"https://api.github.com/users/ocke/following{/other_user}","gists_url":"https://api.github.com/users/ocke/gists{/gist_id}","starred_url":"https://api.github.com/users/ocke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocke/subscriptions","organizations_url":"https://api.github.com/users/ocke/orgs","repos_url":"https://api.github.com/users/ocke/repos","events_url":"https://api.github.com/users/ocke/events{/privacy}","received_events_url":"https://api.github.com/users/ocke/received_events","type":"User","site_admin":false},"body":"can this be falsey?","created_at":"2018-08-28T00:58:21Z","updated_at":"2018-08-28T00:58:50Z","html_url":"https://github.com/zendesk/linked_ticket_app/pull/81#discussion_r213157847","pull_request_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/comments/213157847"},"html":{"href":"https://github.com/zendesk/linked_ticket_app/pull/81#discussion_r213157847"},"pull_request":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81","id":210688737,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNjg4NzM3","html_url":"https://github.com/zendesk/linked_ticket_app/pull/81","diff_url":"https://github.com/zendesk/linked_ticket_app/pull/81.diff","patch_url":"https://github.com/zendesk/linked_ticket_app/pull/81.patch","issue_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/81","number":81,"state":"open","locked":false,"title":"[OFFAPPS-1024] - LTA warns agent and stops crashing when linked data field is missing from any form","user":{"login":"vaevictis","id":321064,"node_id":"MDQ6VXNlcjMyMTA2NA==","avatar_url":"https://avatars1.githubusercontent.com/u/321064?v=4","gravatar_id":"","url":"https://api.github.com/users/vaevictis","html_url":"https://github.com/vaevictis","followers_url":"https://api.github.com/users/vaevictis/followers","following_url":"https://api.github.com/users/vaevictis/following{/other_user}","gists_url":"https://api.github.com/users/vaevictis/gists{/gist_id}","starred_url":"https://api.github.com/users/vaevictis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vaevictis/subscriptions","organizations_url":"https://api.github.com/users/vaevictis/orgs","repos_url":"https://api.github.com/users/vaevictis/repos","events_url":"https://api.github.com/users/vaevictis/events{/privacy}","received_events_url":"https://api.github.com/users/vaevictis/received_events","type":"User","site_admin":false},"body":"## Description\r\n- [x] The LTA stopped warning agent that the linked data field (requirement or setting) is missing in current form. This PR re-establishes this behaviour.\r\n- [x] When this would happen, the LTA would crash and send a JS error in the browser console.\r\n\r\n## Tasks\r\n- [x] Write tests\r\n\r\n## Implementation notes\r\n- I just wrap the field-hiding code within two nested loops for forms then fields. See Risks potential performance impacts.\r\n- The agent will be notified if _any_ form lacks the setting (if it's a legacy install of the app) or requirement field, with detailed info about missing field and problematic form(s).\r\nWe could imagine a feature where the notification only focuses on the currently visible form missing data field(s), but it's not how all other apps behave.\r\n\r\n## References\r\n[JIRA ticket](https://zendesk.atlassian.net/browse/OFFAPPS-1024)\r\n\r\n## CCs\r\n@zendesk/apps-migration\r\n@sostopher for the potential complexity / performance issue in **Risks**. I need an estimate of our biggest numbers of forms and fields.\r\n\r\n## Risks\r\n* [low] Only adds an extra iteration over form objects. Only thing: what are the maximum combination of form objects and form fields our customers have? I'm using nested loops there.","created_at":"2018-08-24T09:36:09Z","updated_at":"2018-08-28T00:58:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"420f4ea031f31601380ce1c539c08a83cd7e2030","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81/commits","review_comments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81/comments","review_comment_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/81/comments","statuses_url":"https://api.github.com/repos/zendesk/linked_ticket_app/statuses/9f2041b40ca1ce33504bdb0593a122fa5e1f3a7d","head":{"label":"zendesk:gh/require_linked_data_field_in_form","ref":"gh/require_linked_data_field_in_form","sha":"9f2041b40ca1ce33504bdb0593a122fa5e1f3a7d","user":{"login":"zendesk","id":11525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/11525?v=4","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":11429698,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQyOTY5OA==","name":"linked_ticket_app","full_name":"zendesk/linked_ticket_app","owner":{"login":"zendesk","id":11525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/11525?v=4","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/linked_ticket_app","description":"This is Zendesk's linked ticket App","fork":false,"url":"https://api.github.com/repos/zendesk/linked_ticket_app","forks_url":"https://api.github.com/repos/zendesk/linked_ticket_app/forks","keys_url":"https://api.github.com/repos/zendesk/linked_ticket_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/linked_ticket_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/linked_ticket_app/teams","hooks_url":"https://api.github.com/repos/zendesk/linked_ticket_app/hooks","issue_events_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/linked_ticket_app/events","assignees_url":"https://api.github.com/repos/zendesk/linked_ticket_app/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/linked_ticket_app/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/linked_ticket_app/tags","blobs_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/linked_ticket_app/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/linked_ticket_app/languages","stargazers_url":"https://api.github.com/repos/zendesk/linked_ticket_app/stargazers","contributors_url":"https://api.github.com/repos/zendesk/linked_ticket_app/contributors","subscribers_url":"https://api.github.com/repos/zendesk/linked_ticket_app/subscribers","subscription_url":"https://api.github.com/repos/zendesk/linked_ticket_app/subscription","commits_url":"https://api.github.com/repos/zendesk/linked_ticket_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/linked_ticket_app/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/linked_ticket_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/linked_ticket_app/merges","archive_url":"https://api.github.com/repos/zendesk/linked_ticket_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/linked_ticket_app/downloads","issues_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/linked_ticket_app/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/linked_ticket_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/linked_ticket_app/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/linked_ticket_app/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/deployments","created_at":"2013-07-15T17:59:41Z","updated_at":"2018-08-24T09:18:03Z","pushed_at":"2018-08-27T15:02:31Z","git_url":"git://github.com/zendesk/linked_ticket_app.git","ssh_url":"git@github.com:zendesk/linked_ticket_app.git","clone_url":"https://github.com/zendesk/linked_ticket_app.git","svn_url":"https://github.com/zendesk/linked_ticket_app","homepage":null,"size":1736,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":9,"open_issues":3,"watchers":4,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"4ac670c3e1ec334aafddf7a0e9033423736dd2f8","user":{"login":"zendesk","id":11525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/11525?v=4","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":11429698,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQyOTY5OA==","name":"linked_ticket_app","full_name":"zendesk/linked_ticket_app","owner":{"login":"zendesk","id":11525,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExNTI1","avatar_url":"https://avatars3.githubusercontent.com/u/11525?v=4","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/linked_ticket_app","description":"This is Zendesk's linked ticket App","fork":false,"url":"https://api.github.com/repos/zendesk/linked_ticket_app","forks_url":"https://api.github.com/repos/zendesk/linked_ticket_app/forks","keys_url":"https://api.github.com/repos/zendesk/linked_ticket_app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/linked_ticket_app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/linked_ticket_app/teams","hooks_url":"https://api.github.com/repos/zendesk/linked_ticket_app/hooks","issue_events_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/linked_ticket_app/events","assignees_url":"https://api.github.com/repos/zendesk/linked_ticket_app/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/linked_ticket_app/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/linked_ticket_app/tags","blobs_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/linked_ticket_app/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/linked_ticket_app/languages","stargazers_url":"https://api.github.com/repos/zendesk/linked_ticket_app/stargazers","contributors_url":"https://api.github.com/repos/zendesk/linked_ticket_app/contributors","subscribers_url":"https://api.github.com/repos/zendesk/linked_ticket_app/subscribers","subscription_url":"https://api.github.com/repos/zendesk/linked_ticket_app/subscription","commits_url":"https://api.github.com/repos/zendesk/linked_ticket_app/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/linked_ticket_app/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/linked_ticket_app/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/linked_ticket_app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/linked_ticket_app/merges","archive_url":"https://api.github.com/repos/zendesk/linked_ticket_app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/linked_ticket_app/downloads","issues_url":"https://api.github.com/repos/zendesk/linked_ticket_app/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/linked_ticket_app/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/linked_ticket_app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/linked_ticket_app/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/linked_ticket_app/releases{/id}","deployments_url":"https://api.github.com/repos/zendesk/linked_ticket_app/deployments","created_at":"2013-07-15T17:59:41Z","updated_at":"2018-08-24T09:18:03Z","pushed_at":"2018-08-27T15:02:31Z","git_url":"git://github.com/zendesk/linked_ticket_app.git","ssh_url":"git@github.com:zendesk/linked_ticket_app.git","clone_url":"https://github.com/zendesk/linked_ticket_app.git","svn_url":"https://github.com/zendesk/linked_ticket_app","homepage":null,"size":1736,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":9,"open_issues":3,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81"},"html":{"href":"https://github.com/zendesk/linked_ticket_app/pull/81"},"issue":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/81"},"comments":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/linked_ticket_app/statuses/9f2041b40ca1ce33504bdb0593a122fa5e1f3a7d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ocke"}}