Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set HTML to custom web panel

abc pqr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 4, 2023

Hi,

I am new to JIRA. My requirement is as follows.

"Create a button and when clicked invoke an API and display the response in a custom web panel"

 

Button (Custom Web Item):

<web-item key='generate-test-scenarios' name='ScriptRunner generated web item - generate-test-scenarios' section='operations-top-level' weight='70'>
  <label>Generate Test Scenarios</label>
  <condition class='script:true'>
    <param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.jira.fragments.CustomWebItem"}' />
    <param name='£fragmentParameters' value='{"id":"17c8c735-4903-4227-bd89-6bf5d5c8996a"}' />
  </condition>
  <styleClass> sr-generate-test-scenarios sr-trigger-dialog</styleClass>
  <link linkId='sr-generate-test-scenarios'>/rest/scriptrunner/latest/custom/generateCustomText?issueId=${issue.key}</link>
</web-item>

REST Endpoint:

@BaseScript CustomEndpointDelegate delegate

generateCustomText(httpMethod: "GET", groups: ["jira-administrators"]) { MultivaluedMap queryParams, String body ->
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueId = queryParams.getFirst("issueId")

def issueManager = ComponentAccessor.getIssueManager()
Issue issue = issueManager.getIssueObject(issueId)


def description = issue.description

// REMOVED THE BUSINESS LOGIC FOR READABLITY
// DO SOMETHING WITH THE DESCRIPTION (CUSTOM LOGIC)

// TODO: SET TO "Custom Result" Web Panel

return Response.ok().build()
}

 

Custom Result (Web Panel)

<web-panel key='customResult' name='ScriptRunner generated web panel - customResult' location='atl.jira.view.issue.left.context' weight='10' class='script:writer.write("Place Holder for API response")'>
  <label>Custom API Result</label>
  <condition class='script:true'>
    <param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.jira.fragments.CustomWebPanel"}' />
    <param name='£fragmentParameters' value='{"id":"5ebb4df9-cd1e-4d0a-bd95-fda2436f4039"}' />
  </condition>
  <param name='lazy' value='true' />
</web-panel>

I tried setting to Custom Field and able to set the data in REST endpoint function but I am able not able to figure out how to set the value as HTML to a Custom WebPanel. I am not able to find a way to get this Web Panel in the code. I am able to see the 'customResult' web panel added to the JIRA issue with default text. Kindly help me with any examples for the same. Thanks in advance!

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.20.13
TAGS
AUG Leaders

Atlassian Community Events