Hello,
I have a listener script (issue updated event), I would like to trigger a custom web item from it.
How can I do it?
Thanks,
Daniel
You can not.
Listeners are things that occur in the background in response to application events. Those events may be triggered by people using the UI, but could also be triggered by code or remote calls. In which case, the computer has nowhere to run a custom web item.
There is no UI for a listener to work with, so there's nothing you can do here.
Could you explain what you are trying to achieve for your people? We may be able to point you at a way to do what you want if we know what the goal is.
Thank you @Nic Brough -Adaptavist-
Yes,
I am trying to create a dialog popup (with 'ok' button) that will triggered by 'issue updated' event (with some conditions).
So I succeed to call the rest endpoint script (of the dialog) using listener, but the listener return me the section html code by text and didn't show the dialog.
I think that maybe if the listener trigger a fragments that triggered the rest endpoint script it will work.
This is the listener:
def process = ['bash', '-c',('curl -k -u dbajira:dbajira -X GET -H "Content-Type: application/json" https://<jira base utl>/rest/scriptrunner/latest/custom/doSomething' )].execute()//Process process = command.execute()def out = new StringBuffer()def err = new StringBuffer()process.consumeProcessOutput(out, err)process.waitFor()if( out.size() > 0 ) log.warn("out = " +out)if( err.size() > 0 ) log.warn("err = " +err)
This is the rest enspont :
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegateimport groovy.transform.BaseScript
import javax.ws.rs.core.MediaTypeimport javax.ws.rs.core.MultivaluedMapimport javax.ws.rs.core.Response@BaseScript CustomEndpointDelegate delegate
doSomething { MultivaluedMap queryParams ->
// get a reference to the current page...// def page = getPage(queryParams)
def dialog ="""<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true"><header class="aui-dialog2-header"><h2 class="aui-dialog2-header-main">Some dialog</h2><a class="aui-dialog2-header-close"><span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span></a></header><div class="aui-dialog2-content"><p>This is a dialog...</p></div><footer class="aui-dialog2-footer"><div class="aui-dialog2-footer-actions"><button id="dialog-close-button" class="aui-button aui-button-link">Close</button></div><div class="aui-dialog2-footer-hint">Some hint here if you like</div></footer></section>"""
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()}
This is the listener log:
2020-04-19 11:23:49,215 WARN [runner.ScriptBindingsManager]: out = <section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true"> <header class="aui-dialog2-header"> <h2 class="aui-dialog2-header-main">Some dialog</h2> <a class="aui-dialog2-header-close"> <span class="aui-icon aui-icon-small aui-iconfont-close-dialog">Close</span> </a> </header> <div class="aui-dialog2-content"> <p>This is a dialog...</p> </div> <footer class="aui-dialog2-footer"> <div class="aui-dialog2-footer-actions"> <button id="dialog-close-button" class="aui-button aui-button-link">Close</button> </div> <div class="aui-dialog2-footer-hint">Some hint here if you like</div> </footer> </section> 2020-04-19 11:23:49,217 WARN [runner.ScriptBindingsManager]: err = % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 922 0 922 0 0 3073 0 --:--:-- --:--:-- --:--:-- 3073
OK, well, as I said already, a listener is of no use to you because it has nothing to do with the UI (because it may well be triggered by things outside the UI)
You should do your pop-up box with a plugin or something that can amend the front-end of Jira where there is a UI, and remember that it won't happen if something triggers an update outside the UI. Listeners and rest end-points are not the way to get UI elements done.
I think it might be worth exploring what you are trying to achieve here for your end users. What is this pop up box actually for?
Thank you @Nic Brough -Adaptavist- ,
If the 'fix version' of an issue is changed, I would like to check if it match the 'Product Name' field (single select list).
I have a field with all of the options of these two fields (examples: "1.1.1_productOne" , "1.1.2_productOne", 1.1.1_productTwo" - "fixVersion_productName")
If there is no match of these two fields, I want to make a pop up window to the user that tell him that he did something wrong. a message util isn't good for us,cause it's disapear after few seconds..
It looks like you're new here. Sign in or register to get started.