Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Script runner for Jira Cloud

Hi,

I am new to JIRA and using a trial version of JIRA and install Script runner for JIRA, Enhanced Search in my instance.

I am writing a simple script listener as below.

But it says "unable to resolve class com.atlassian.jira.user.util.UserMessageUtil"

Can you help with fixing this issue? - Thanks

 

// Example: Display a success message after an issue is created
import com.atlassian.jira.user.util.UserMessageUtil

 

// ... inside a script listener ...

 

def userMessageUtil = ComponentAccessor.getOSGiComponentInstanceOfType(UserMessageUtil.class)

 

userMessageUtil.displayInfoMessage(currentUser, "Issue created successfully!")

4 comments

Comment

Log in or Sign up to comment
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2024

Hello @Sathishkumar Sundaram 

Welcome to the Atlassian community.

From where did you get that example script? Are you sure it was for Jira Cloud rather than Jira Server/Data Center?

This is the vendor provided page of example Listener Scripts for Jira Cloud:

https://docs.adaptavist.com/sr4jc/latest/features/script-listeners/script-listener-examples

Ryan M
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.
December 16, 2024

Hi @Sathishkumar Sundaram - as Trudy surmised, this is only valid in on premise versions of jira and it sounds like you're on a trial of Jira Cloud. The above package is a reference to the atlassian java API. The atlassian java api is not something available in Jira Cloud, only the Jira Cloud REST API is exposed in the cloud. You can use other publicly available java or groovy packages with ScriptRunner.

Sathishkumar Sundaram December 17, 2024

Hi Trudy/Ryan - I pulled it from web search.

Now understood, its not for Jira cloud. Thanks for pointing this.

Now I have different question with JIRA automation rules.

While the below code to get the date difference of start date (custom field) works,

{{issue.customfield_10015.diff(now).days}} 

I am getting a blank value returned if I use the code 

{{issue.customfield_10015.diff({issue.parent.customfield_10015}).days}}

 

How do I fix this? Thanks in advance with any inputs.

 

Got a solution: Not sure.... how to reply on my own comments. Hence editing....

Syntax used is incorrect. Here is the correct syntax that worked....

{{issue.customfield_10015.diff(issue.parent.customfield_10015).days}}

Ryan M
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.
December 17, 2024

Glad you got your answer @Sathishkumar Sundaram  - best practice would be to select the answer that best answered your question and create a new post for a different question. 

Like Sathishkumar Sundaram likes this
TAGS
AUG Leaders

Atlassian Community Events