Open dialog in Jira Cloud using Javascript

Hello, community,
trying to open dialog2 from dialog1 using javascript atlassian connect Add-on for JIRA Cloud.
web-items in atlassian-connect.json:

        "webItems": [
            {
                "name": { "value": "Dialog 1" },
                "url": "/dialog1",
                "key": "dialog1",
                "location": "opsbar-section-custom",
                "weight": 100,
                "context": "addon",
                "target": {
                    "type": "dialog"
                }
            },
            {
     	    	"name": {
     	    		"value": "Dialog2"
     	    	},
     	    	"url": "/dialog2",
     	    	"key": "dialog2",
     	    	"location": "none",
     	    	"context": "addon",
     	    	"target": {
     	    		"type": "dialog",
     	    		"options": {
     	    		}
     	    	}
     	    }
        ],
        "webSections": [
            {
                "name": { "value": "Custom Section" },
                "location": "opsbar-operations",
                "key": "opsbar-section-custom"
            }
        ],

To open a dialog2 I use the following javascript in dialog1’s template:

AP.require("dialog", function(dialog) {
    dialog.create({
        key: "dialog2",
        width: '500px',
        height: '300px',
        customData: {
	}
    }).on('close', function(data) {
      if (data) {
      }
    });
});

dialog2 is not opened. The same functionality works in Confluence Cloud and dialog2 is opened.

Any ideas how to make dialog2 be opened? Examples of how to open a dialog2 will be much appreciated.

Thank you.

The fact that you can open a web-item as a dialog link in Confluence is lucky and a side-effect that was not intended to work. The correct way to declare a dialog that can be opened via Javascript is via the Dialog Module in your descriptor.

Please try the same Javascript but pointing to a key from a dialog module instead and let me know if that works for you. Cheers!

2 Likes

Thank you, rmassaioli, for clarifying! “dialogs” module didn’t work on previous versions of jira/atlassian-universal-plugin-manager-plugin/atlassian-connect (running the app locally using atlas-run-standalone). After the version upgrade of the versions ‘dialogs’ module started to work.

Thanks.

1 Like

I’m really happy that it worked for you but I would like to strongly encourage you to stop using atlas commands to perform cloud development. Use our free (though limited) cloud development environments instead. The atlas commands have not been supported for cloud development for a very long time and are now scarily out of date from production.

Please don’t hesitate to ask more questions if you have them!