Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with JIRA groovy script

DILEEP KUMAR March 26, 2018

1). How to read the custom field value ?

2). How to make issue type ?

3). How to link the issue type ?

Please help me with groovy script for above requirement.

1 answer

0 votes
Vasiliy Zverev
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.
March 26, 2018

Hi Deller,

1) Here is a code to get custom field value:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField

//Define custom field variable
CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("field name")

//Definr issue variable. There is a build-in variable into script postfucntions, conditions and validators.
//Since this line should be commented
Issue issue = ComponentAccessor.getIssueManager().getIssueObject("issue key")

//get custom field value
issue.getCustomFieldValue(customField)
//or
customField.getValue(issue)

2) What do you mean "make issue type" - does it mean to change issue type?

3) There  is no link "issue type". The only option - change issue type.

 

Best regards, 

Vasiliy

DILEEP KUMAR March 26, 2018

Thanks Vasily for your response !!

2) What do you mean "make issue type" - does it mean to change issue type?

I want to create my own issue type, based on the custom field condition.

Suppose, if the custom field value is no then do nothing. If it's yes create the new  issue type with name "Bug". 

This is what i want.

Vasiliy Zverev
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.
March 26, 2018

You see, issue type is one of basic values of an issue. Because with it issues assotianted with workflow, screent scheme, field configuration scheme. So, change issue type is very difficalt operation. 

Do you want to create new issue from current or you want to change issue type of current one?

DILEEP KUMAR March 26, 2018

Thanks Vasiliy !!

So, If i want to create my own issue type, what changes required in JIRA and how it will impact the overall process ?

If you can help me with groovy script, how can i read the value from available issue type and change issue type of current one ?

Regards,

Dileep.

Vasiliy Zverev
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.
March 27, 2018

Usually need to change issue type in script means that Jira is used into incorrect way. 

Here is documentation for issue types: https://confluence.atlassian.com/adminjiracloud/adding-editing-and-deleting-an-issue-type-844500747.html

You need no code for this.

DILEEP KUMAR March 27, 2018

Thanks Vasiliy !!

Regards,

Dileep.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events