Context variables are not available immediately when getting them from AP.context.getContext() in the New issue view

XMLWordPrintable

    • Severity 2 - Major

      Summary

      When trying to get context parameters thru AP.context.getContext(), no response is returned immediately. Repeating calls were made to AP.context one per 5 seconds. First several results didn't have the issue key, and context was an empty object. Issue key appeared after 30 seconds only:

      API is invoked when frame is loaded an script starts working:

      export function getIssueKey() {
          return new Promise((resolve, reject) =>{
              try {
                  AP.context.getContext(
                      context => {
                          const issueKey = access('jira.issue.key', context)
                          if (issueKey) {
                              // console.log('issue key is resolved', issueKey)
                              resolve(issueKey)
                          } else {
                              //console.log('issue key is not resolved', context)
      
                              // I noticed that context is an empty object in this case,
                              // try to get issueKey from URL parameters:
                              const params = getQueryParams(location.search)
                              resolve(params['issue.key'])
                          }
                      }
                  )
              } catch(e) {
                  reject(e)
              }
          })
      }
      

      Notes

      • Works in old issue view
      • iframe is nor cacheable
      • Not sure if this is by design

            Assignee:
            Unassigned
            Reporter:
            Anne Calantog
            Votes:
            7 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: