Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Displaying a searchable list of users in a generated dialog pop-up Edited

Hello :)

I have set-up a script fragment with an associated REST Endpoint, to generate a dialog pop-up (please see screenshot). The current implementation is that the user selects as assignee from a drop-down list, an issue type from a drop-down list, and hits create to clone the current task as a sub-task, with the selected parameters from the pop-up.

The issue is that having a drop-down select list of assignees is bad as it isn't scalable. My intended implementation is for the assignee field to act similarly to the reporter/assignee field when creating an issue, where the user can start typing a name and a list of suggestions appears and updates with every keystroke. I'm struggling to figure out a way of making this happen.

My research leads me to believe that I need to use a custom field embedded within HTML in some way. However I'm at a total loss with how to do this. I'm not even sure if using a custom field is the right way to go about implementing this, is there some other way that I've missed.?

Below is my code for displaying the pop-up dialog, as you can see right now it displays the assignees as select options within a form. Any direction would be very much appreciated, thank you.

import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.properties.APKeys

@BaseScript CustomEndpointDelegate delegate

cloneSubTaskDialog { MultivaluedMap queryParams ->

def issueKey = queryParams.getFirst("issueKey").toString()
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueKey)

// createIssue endpoint to run upon submitting form
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def actionUrl = """
${baseUrl}/rest/scriptrunner/latest/custom/cloneAsSubTask?
"""

def header = """
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main">Clone ${issueKey} as Sub-Task</h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span>
</a>
</header>
"""


def assigneeSelectHTML = ""
ComponentAccessor.userManager.getAllApplicationUsers().each { type ->
assigneeSelectHTML += "<option value=${type.name}>${type.name}</option>"
}

def issueTypesSelectHTML = ""
ComponentAccessor.constantsManager.subTaskIssueTypeObjects.each { type ->
issueTypesSelectHTML += "<option value=${type.id}>${type.name}</option>"
}

def content = """
<div class="aui-dialog2-content">
<p>Select an assignee and issue type for the Sub-Task</p><br>
<form id="clone-form" class="aui" action="${actionUrl}">
<p>Assignee</p>
<select name="assigneeId">
${assigneeSelectHTML.value}
</select><br><br>
<p>Issue type</p>
<select name="issueTypeId">
${issueTypesSelectHTML.value}
</select>
<input name='projectId' type='hidden' value="${issue.getProjectId()}">
<input name='reporterId' type='hidden' value="${issue.reporterId}">
<input name='summary' type='hidden' value="${issue.summary}">
<input name='description' type='hidden' value="${issue.description}">
<input name='priorityId' type='hidden' value="${issue.priority.id}">
<input name='parentId' type='hidden' value="${issue.getId()}">
</form>
</div>
"""

def footer = """
<footer class="aui-dialog2-footer">
<div class="aui-dialog2-footer-actions">
<button type="submit" form="clone-form" class="aui-button aui-button-primary">Create</button>
</div>
<div class="aui-dialog2-footer-hint">All issue details will be copied over into the new Sub-Task</div>
</footer>
"""

def dialog = """
<section id="static-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" role="dialog" aria-hidden="true">
${header}
${content}
${footer}
</section>
"""

Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}

 

dialog.PNG

1 answer

1 accepted

1 vote
Answer accepted

Hi Luke,

Thank you for your question.

I can confirm that ScriptRunner for Jira Server only has limited support for Dialogs as described in the documentation page located here.  

This means that with dialogs that to anything advanced such as creating a field which searches for users that you would need to write a bespoke javascript function that would search for the users that were typed in the field, as ScriptRunner for Jira Server contains no built in functionality to be able to put standard Jira custom fields such as User Picker fields on the Dialog.

I understand that this response is frustrating but please understand that the methods do not exist to create this functioanlity as explained above.

Regards,

Kristian

:'(

No worries, thank you for the response.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Why everyone using Jira must be GDPR-compliant

Did you know that penalties up to 4 % of the yearly company turnover are possible in case of GDPR violations? GDPR regulations are currently mainly relevant for companies in the EU, but countries lik...

81 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you