Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript Code in ScriptRunner-Behaviours ?

Maru Sravan January 8, 2024

To address the delay in response caused by two dependent custom fields in Jira,
Here the question is: "How can I execute the JavaScript code within ScriptRunner Behaviours to manage the loader option, considering that two custom fields are interdependent?"

1 answer

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2024

"What?" What delay.

You don't run js directly off behaviours. They do "trigger certain javascript" on issue forms, but you are writing groovy scripts, not javascript.

Maru Sravan January 9, 2024

Thanks for your reply @Radek Dostál 

I've established two custom fields with interdependencies, and for the initial field, I'm using a Groovy script to invoke an API. However, due to a delay in the API response, I'm looking to implement a loader icon or spinner. My current approach involves executing JavaScript code within the Groovy script to keep a loader icon
.

Alternatively, if you have any other suggestions for incorporating a loader icon or spinner, I'm open to exploring alternate approaches.


jabrealmoe1 March 22, 2024

Radek,

 

you can actually use Fragments and Groovy, to write JavaScript in scriptrunner. You only need to pass the JavaScript or html to the writer.write function. I’ve built lots of custom web panels using this approach.

 

writer.write(“””

<script>
function myfunction(){
    alert(‘Hi Mom!’);

}

</script>

<button onclick=“myfunction()”>Greeting</button>

”””) // all this happens in the write function 🤫🤔

Like ihor.zozuliak likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events