Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Error message didn't shown to issue with subtasks

Hello,

 

I have a listener 'issue updated' that catch the event of changing issue type, check some fields of the issue, and display an error message.

This code worked ok, Instead a scenario which the issue has subtask.

I put logs inside the code, and I can see the UserMessageUtil.error line is read but isn't display in the issue view..

This is my code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.ComponentManager

Issue issue = event.getIssue()
def issueType=issue.getIssueType().name;
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)

def sub = issue.getSubTaskObjects();
log.warn sub
if(sub!=null)
{
def SubIssue = ComponentAccessor.getIssueManager().getIssueObject(sub[0].toString());
log.warn SubIssue
def issueCur= SubIssue.getParentObject();
log.warn issueCur;
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "issuetype"}
log.warn change;
def newString = change.newstring;
def oldString = change.oldstring;

log.warn newString
log.warn oldString

//old type is Bug-Customer
if((newString.toString()=='Story' || newString.toString()=='Bug-Internal' || newString.toString()=='Doc Story' || newString.toString()=='Integration'
|| newString.toString()=='QVR' || newString.toString()=='Epic' || newString.toString()=='UX Story' || newString.toString()=='Feature'
|| newString.toString()=='Theme') && (oldString.toString()=='Bug-Customer'))
{
log.warn 1;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def Salesforce = issueCur.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14309"));
log.warn Salesforce

if(Salesforce!=null)
{
log.warn 5
UserMessageUtil.error("<div style='color:red;'><b>Your move has changed the Issue Type for an Issue that has an external Salesforce ID to an Issue Type that is not synchronized with Salesforce and should not have a Salesforce ID.<br>Please contact a Jira administrator for more information.</b></div>");
log.warn 55

}

}

}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

94 views 0 5
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