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.
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 window.name 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.
EDIT
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.
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 (Log in with Atlassian account).
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 ([ACJS-906] - Ecosystem Jira).