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,465,462
Community Members
 
Community Events
176
Community Groups

Scriptrunner custom screen on customer portal using script fragment

Hi - probably a basic question as i'm just getting to grips with scriptrunner.. 

We are building an issue hierarchy from one of our service desk portals.  One of the tasks is to allow a user to create a linked issue with certain user-entered fields, from the parent issue.  Essentially a button on the customer portal, that goes to a custom screen, which allows the user to input a few required fields, and then create the linked issue.  This works fine in agent view & we can achieve this using normal Jira functionality

however I'm trying to get this working as a customer

I've tried creating a 'constrained create issue' web part, which does allow a transition to a the create issue screen for the issue type.. not quite custom but it'll do.. when clicking the button - but the conditional validation doesn't work (it looks like the jiraHelper object isn't available in the customer portal).   So I'm looking for a bit of advice on the jiraHelper issue? or if anyone's done something similar in the customer portal and has a much better way of doing this that would be fantastic

The basic idea is: in the customer portal view of an issue -> click a button -> add in some specific information -> create & link a new issue.


1 answer

0 votes

The question is basic... but not the solution.

I'm not aware of any built-in way to prompt customers for additional information on a request.

There might be add-ons that offer some forms, but the only built-in form is the new request form.

From scriptrunner standpoint, you might be able use the Web Item with "run code and display a dialog" method (this won't work with Refined for JSM). 

But you'd need to build a custom dialog2 form in HTML and serve it as custom rest endpoint.
And you'd need to write javascript to call an api (built-in or custom depending on your need) to create the linked issue.

Thanks for your reply! I'd rather not build a custom form in HTML and run a custom rest endpoint etc. as that would be quite cumbersome to maintain, as well as not be compatible with refined (which we're looking to implement at some point as well!) .. 

Any thoughts on why the jiraHelper object isn't available through the portal? something that I should raise with Adaptavist themselves or is this 'expected behaviour'?

I've heard Actions for Jira has this functionality, but it takes time to onboard a new plugin / plugin vendor as we have a governance process in place to ensure we don't just go wild and expose our data / cost money without due cause.. 

I've been meaning to reach out to Refined about the availability of the dialog2 (and many other AUI components) in their javascript layer to be able to implement custom dialog etc.

Yes, the availability of jiraHelper in the portal is probably a question for adaptavist.

But I'm not sure that would help you. I don't think you can get the "constrained create issue" would work in this case, it is designed to work within jira with jira permission.

I don't think it would work with portal permissions even if you were able to trigger it to pop up.

So as it turns out, enabling the dialog2 functionality in Refined is all on our end.

And it's not all that hard

Here is a sample javascript that you can post via "install web resource" fragment in the context "refined.customer-portal":

//load the dialog functionality
WRM.require('wrc!com.atlassian.auiplugin:dialog2').done(function(){
console.log('Loaded AJS.dialog2', AJS.dialog2);
});
//add additional aui components you might want to use in the loadl
WRM.require('wrc!com.atlassian.auiplugin:aui-toggle').done(function(){
console.log('Loaded aui-toggle');
});

//bind click events on SR webItems to get and display a dialog
AJS.toInit(function () {
var srWebItemelector = '[id^="com.onresolve.jira.groovy.groovyrunner"]'
AJS.$('body').on('click', srWebItemelector, function(clickEvent){
clickEvent.preventDefault();
var href = AJS.$(this).attr('href');
AJS.$.ajax({
type: "GET",
dataType: "html",
url: href
}).done(function(data) {
AJS.dialog2(AJS.$(data)).show();
}).fail(function(jqXHR, textStatus, errorThrown) {
console.warn("Failed to execute remote:", errorThrown);
});
});
});

//add an icon to the custom webitem
AJS.$(document).ajaxStop(function () {
var webItemsParams = [
{menuText:'WebItem MenuText Example', iconClass:'rw_external_helper_icon_escalate'}
]
webItemsParams.forEach((webItem,index)=>{
if(webItem.iconClass){
var itemSelector = `.rw_item_content:contains(${webItem.menuText})`
var item = AJS.$(itemSelector)
item.prev('.rw_item_icon:not(.rw_external_helper_icon_escalate)').addClass(webItem.iconClass)
}
});
})

This will find all the ScriptRunner Web Items and bind an appropriate event to the item so that it will open a dialog instead of navigating to another page. The web item will need to specify "do nothing - you will use js to bind an action".

The second part of the script is optional, but it will add an icon to a specific web item by looking it up by its Menu Text.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events