Redirect from search request view

I’m building out some custom export functionality using a search request view, however I need the user to provide some additional configuration info before performing the actual export. My plan is to build out a form in a generalPages module and have the view returned by the search request view redirect to that page with the filter info, but I’m having a little trouble with the redirect part.

It seems like I should be able to use AP.navigator.go, but for some reason AP is undefined in my search request view. I think this has to do with the fact that the search request view is loaded directly and not in an iframe, but I’m unsure how to get around it.

Relevant modules of atlassian-connect.json:

  "modules": {
    "jiraSearchRequestViews": [
        "url": "/views/search-request",
        "key": "search-request-view"
    "generalPages": [
        "url": "/export-config",
        "key": "export-config-page"

/views/search-request maps to the following simple page:

<!doctype html>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="ap-local-base-url" content="{{localBaseUrl}}">
  <script src="{{hostScriptUrl}}" type="text/javascript"></script>
  <script type="text/javascript">
    AP.navigator.go('addonModule', { addonKey: {{addonKey}}, moduleKey: 'export-config-page'});

Once the search request page loads, even trying to access AP from the console shows that it’s undefined.

After some more digging into the all-debug.js script, I noticed it’s erroring out at line 3177:

AP$2.env.hideFooter(ConsumerOptions$1.get('hideFooter') === true);

Saying that AP$2.env is undefined. Again this only happens when loading in the search request view.

I don’t see you loading the actual AP scripts:

<script src="{baseUrl}/atlassian-connect/all.js"></script>

That might be the problem.

I’m using ACE, so the all-debug.js script should be loaded by {{hostScriptUrl}}:

<script src="{{hostScriptUrl}}" type="text/javascript"></script>

When I inspect the resources in the browser, I can see that it is in fact loaded

Ok, I wasn’t sure you were using ACE.

@mstaas, @dboyd, or @rmassaioli do you know what might be the problem here?

Do you have a dev server running where I can try to debug your app from?

1 Like

I ended up implementing the redirect server-side as a workaround, so I don’t have an example on my server anymore. However, it could be easily reproduced with a search request view containing the html in the original question.

I did look more into the all-debug.js script and found that it seems to be reliant on the name attribute that is set on the iframe when loading a page. When loading outside an iframe without set, the AP object is missing an env variable which causes an error when the script checks for data-options that have been passed in.


More info about the actual redirect solution for anyone looking: You can get the host url server-side from req.context.hostBaseUrl, and your project key is available via the addon object. With that you can construct the target url as {{hostUrl}}/plugins/servlet/ac/{{addon.key}}/{{pageModuleKey}} and redirect as normal.

1 Like

Ah, the Connect JSAPI relies entirely on being in an iframe with the API metadata in the name so it would never work without it.

Looking further into it, it appears the JSAPI (AP) doesn’t work in the context of the Search Request View module type. The documentation should be updated to make this clearer (

This could possibly be raised as a feature request for an improvement to the Search Request View module type.

AP should also be updated to issue a warning like “AP is expecting to be in a Connect iframe but doesn’t appear to be” rather than falling over cryptically (

1 Like