We want to open create JIRA issue form on click of a button
Asked by Abhishek Barnwal:

When we hover on the text in confluence page, it gives an option to create JIRA issue. We want to open the same JIRA issue create form on click of a button. We have scriptrunner for confluence. I have added an approve button on the confluence page. Requirement is once the user clicks on the approve button JIRA issue create form should popup.

Thanks!


Answers:
author: Nic Brough -Adaptavist-
body: For server, I would create a user macro to provide the approve button and link to the issue create screen - you can't put it in as part of a Confluence page, it would have to be a callout to Jira.

Or use a Jira "issue collector" in your space or global headers.

Or consider Confluence forms with SR - <https://library.adaptavist.com/entity/create-jira-issue-from-forms-for-confluence-submission>

comments: author: Abhishek Barnwal
body: Is there a way we can call JIRA macro using scriptrunner?


author: Nic Brough -Adaptavist-
body: You don't need to call the Jira macro with Scriptrunner, you can use the Jira macro directly in the body of your page.

You can alter the Confluence UI with Scriptrunner though - see <https://docs.adaptavist.com/sr4c/latest/features/script-fragments> and those could be used to call scripts.


author: Abhishek Barnwal
body: I use below snippet to insert the JIRA issues using automation for dynamic creation of confluence pages.

JIRA insert issue macro

\<ac:structured-macro ac:name='jira' ac:schema-version='1'\>\<ac:parameter ac:name='columns'\>component,type,key,summary,created\</ac:parameter\>\<ac:parameter ac:name='maximumIssues'\>20\</ac:parameter\>\<ac:parameter ac:name='jqlQuery'\>'project=ABC'\</ac:parameter\>\</ac:structured-macro\>

Is there any code for JIRA Create issue macro ?


author: Lukasz Sielski
body: Hi,

you can play around with this, create rest endpoint with this code

and call it using script fragment.

*** ** * ** ***

```
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.BaseUrl



@BaseScript CustomEndpointDelegate delegate

def constantsManager = ComponentAccessor.getConstantsManager()
def commsIssueType = constantsManager.getAllIssueTypeObjects()

customCreateSubTask(httpMethod: "GET") { MultivaluedMap queryParams ->

    // getting information about current issue and base url
    def BaseUrl baseUrl = ComponentAccessor.getComponent(BaseUrl)
    def String parentIssueKey = queryParams.getFirst("key")
    def parentIssue = ComponentAccessor.issueManager.getIssueByCurrentKey(parentIssueKey)
    def parentIssueID = parentIssue.getId()
    
    // creating url for response
    def URL = baseUrl.getBaseUri().toString()
    URL = URL + "secure/CreateSubTaskIssue!default.jspa?parentIssueId=${parentIssueID}&issuetype=xxxxx" //issuetype if needed
    URL =  URL.toURL()

    Response.temporaryRedirect(URI.create("${URL}")).build()
}
```


author: Fabian Lim
body: Adding [@Nic Brough -Adaptavist-](/t5/user/viewprofilepage/user-id/781454)

I'm also interested on this one.


Tags: confluence-server

server