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 edited

"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 edited

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 edited

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
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events