Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
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

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

1 answer

1 accepted

1 vote
Answer accepted

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

⚡️NEW Group for Confluence Cloud Admins

Calling all Confluence Cloud Admins!  We created a new Community Group to support your unique needs as Confluence admins. This is a group where you can ask questions, access resou...

110 views 2 9
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