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

How to add validation for "Issue" which is right below the "Linked Issues" field?

Teja December 6, 2017

Hi, 

I wanted to check the linking issue has a correct custom field value.

i.e. I have custom field 'Feature Type' and values "Product Feature" and "Technical Feature" on the linking issue and now I want to validate this issue on the other issue which going to link and contain Product Feature or not.

Example: Test112.PNG

On the create screen, "GTN-28761" which is going link to another issue and I want to add validation that GTN-28761 has a value of Product Feature or not to show here (another issue create screen).

Thanks

2 comments

Comment

Log in or Sign up to comment
Tarun Sapra
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 6, 2017

In the validation phase of the create transition you will have to check if the custom fields have required values on the linked Issues or not.

How to fetch custom field value (since you already have issue Id of the linked issue thus you can get issue object using IssueManager)

https://community.atlassian.com/t5/Jira-questions/How-to-get-the-custom-field-value-using-by-groovy-script/qaq-p/385870

Code snippets to parse/get info of linked issues (answer form chris duffy)

https://community.atlassian.com/t5/Jira-questions/Validator-script-to-check-status-of-all-linked-issues-before/qaq-p/427966

Tarun Sapra
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 6, 2017

Also, the above samples work if you have script runner plugin installed.

Teja December 6, 2017

Hi Tarun,

Thanks for your reply,

Yeah I have script runner plugin installed in my Jira.

Thanks

Teja December 7, 2017

Hi Tarun,

Can you please help me to get linked issue custom field value?

I am getting confused there.

Thanks

Teja December 7, 2017

Hi Tarun,

I tried this below code, did not work.

I'm a beginner for this Jira thing could you please help me.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.IssueLinkManager
import org.apache.log4j.Category
import com.atlassian.jira.issue.link.IssueLink;
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;

IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager()

def customFieldManager = ComponentAccessor.getCustomFieldManager()
//custom field of linking issue
def cField = customFieldManager.getCustomFieldObject("customfield_18815")

def cField1 = customFieldManager.getCustomFieldObject("customfield_18813")
def cFieldValue1 = issue.getCustomFieldValue(cField)

for (IssueLink link in linkMgr.getInwardLinks(issue.id)) {


if ( (cFieldValue1.toString().contains("Product Feature")) && !(link.getSourceObject().getCustomFieldValue(cField).toString().contains("Product Feature")) ) {

invalidInputException = new InvalidInputException("Linked issue " + link.getSourceObject().getCustomFieldValue(cField) + " is not having right value")
throw invalidInputException
}


}

TAGS
AUG Leaders

Atlassian Community Events