The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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 Champions.
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.


Dr Jira
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
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events