Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,028
Community Members
 
Community Events
184
Community Groups

Display Custom Web Items in a Dialog from Issue Actions on Dashboard

Following the example tutorials from the Scriptrunner fragments documentation, I am able to create an action button for my issues that displays a dialog with content from a REST API. image.pngHowever, when I click on the action from a dashboard's filter list, the button opens the link instead of opening in a dialog. image.pngimage.pngI would like it to open as a dialog in the same way that the workflow transition buttons work. For example, for my transition 'Update CCB', the dialog opens with the screen contents:image.png

Is there any way to do this with Scriptrunner?

Versions:

Jira v8.13.2

JIRA Service Desk Application v4.13.2

Scriptrunner: 6.15.0

2 answers

1 accepted

1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 10, 2021

This is caused by this bug: https://productsupport.adaptavist.com/browse/SRJIRA-2665 (created as a result of a support request I sent them).

My guess is they load some javascript resources to "listen" to the web-item click. But this resource is not available in all issue view contexts.

It's possible to work around it by creating your own javascript resource file somewhere in your script root.

It will look something like this:

(Note that I'm not an expert in javascript and I created this more than 3 years ago. I don't remember whys for much of this code. And there is probably some better ways.)

//Manual binding of the Display Dialog web item since SR-trigger doesn't work well on issue navigators
AJS.toInit(function () {
var webItemKey = 'the-key-for-you-web-item';
var webItemMenuText = 'Show Dialog';
//This catches elements where the ID is not unique (such as issue navigator)
AJS.$('body').off('click', `a.aui-list-item-link:contains('${webItemMenuText}')`).on('click', `a.aui-list-item-link:contains('${webItemMenuText}')`, function(event){
event.preventDefault();
var ancestorAnchor = AJS.$(this).closest("[href]");
AJS.$.ajax({
type: "GET",
dataType: "html",
url: ancestorAnchor.attr("href")
}).done(function(data) {
AJS.dialog2(AJS.$(data)).show();
}).fail(function(jqXHR, textStatus, errorThrown) {
console.warn("Failed to execute remote:", errorThrown);
});
});
//this is for all other issue details
AJS.$('body').off('click', `#${webItemKey}`).on('click', `#${webItemKey}:not(.aui-list-item-link)`, function(event){
event.preventDefault();
var ancestorAnchor = AJS.$(this).closest("[href]");
AJS.$.ajax({
type: "GET",
dataType: "html",
url: ancestorAnchor.attr("href")
}).done(function(data) {
AJS.dialog2(AJS.$(data)).show();
}).fail(function(jqXHR, textStatus, errorThrown) {
console.warn("Failed to execute remote:", errorThrown);
});
});
});

Just update the first 2 var statement with your specifics

Then you create a "install web resource" fragment for your resource file with the following contexts: atl.dashboard greenhopper-rapid-non-gadget jira.view.issue

In your Web Item fragment, change the "Do what" from display a dialog to "do nothing"

Good luck

Hi Peter,

Thank you so much for the help. That worked like a charm.

Hi @Brian Ho  can you share your code. Coz the above mentioned code shows me an Unexpected character error for the string literal used ` . @Peter-Dave Sheehan Can you explain me the concept of Script Root

Thanks

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jul 12, 2021

Hi @Brian Ho 

 

I would like to ask how you display the custom field in your dialog box? Can you provide sample script? Thanks`1

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events