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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Hi , i need to get a custom pop-up message in JIRA as soon as a custom field value is updated.

Hi All,

I have written a script in a listener (Event - Issue created, issue updated) which updates a custom field named as - Incident Classification on the basis of 2 other fields as soon as the issue gets created or updated.

the field  "Incident classification"can have 2 values - Major , Minor.

I have written another listener in which i need to have a pop-up message coming as soon as the value of "Incident Classification" field is set to "Major". 

I am running the listener on the issue create and issue update event but i am not getting the pop-up message always.

Problem statement -

1) as soon as the issue gets created in the view screen i can see that the field Incident classification has been set to Major but the pop-up message does not appears.

2) No pop up message coming - When i am updating the other 2 fields the value of Incident classification gets changed automatically and is set to Major but still the pop up message is not appearing.

Pop-up message is coming only when i am editing the issue by going to edit screen and changing the value of the other 2 fields which in turn changes the value of Incident Classification field and the pop-up message is coming.

Please let me know why the below listener is not working properly - pfb codePop-up messgae.JPG

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.INFO)
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
import com.onresolve.scriptrunner.runner.util.UserMessageUtil

MutableIssue issue = event.issue as MutableIssue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()


def cfds = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Incident Classification'};
String cfdsv = issue.getCustomFieldValue(cfds);
log.info (cfdsv)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false);

if ("Major".equals(cfdsv))
{
log.info (cfdsv)

UserMessageUtil.success("Since this is a Major Incident, please follow the defined Escalation Process")
}

0 comments

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

679 views 17 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you