Forums

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

Get Insight Custom Field value in jira plugin

Yogesh Mude
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.
May 4, 2020

How can I get the Insight Custom field object and its attributes using java api.

1 answer

0 votes
Santiago Estel
Contributor
May 5, 2020

If you are talking about Jira REST API, then try:

http://<your Jira URL/rest/api/2/issue/<issue #>

If you are talking about getting the Insight data, you will need to use Insight API, look here:

https://documentation.mindville.com/insight/5.0/insight-for-developers/insight-rest-api

Yogesh Mude
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.
May 6, 2020

Thank you for the response.

Do you have a reference code for insight rest Api using we can get the insight field attributes?

Yogesh Mude
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.
May 11, 2020

@Santiago Estel ,

Actually I came across this but in my case, the user is selecting the insight object values while issue transition (popup the issue transition screen and the user will select the value), and based on the selection I need to fetch the object attribute and populate to VM file.

Santiago Estel
Contributor
May 13, 2020

Define VM file.

Filip Håkansson
Contributor
May 14, 2020

You will need to use Scriptrunner plugin (or similar) to add some custom code in the post functions of the transtion in case you would like to do something with the insight object user selects in transition screen.

For example:

{code}

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager;
import org.apache.log4j.Logger

def log = Logger.getLogger("com.something.great")
log.warn("Workflow function running...")
def customFieldManager = ComponentAccessor.getCustomFieldManager();

/* The object facade class */
Class objectFacadeClass = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade");
/* The reference to the object facade which you can use in your code */
def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(objectFacadeClass);


def insightObjCF= customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Some Custom Field'}
def insightObjValue = insightObjCF.getValue(issue);

//Load the insight object
def insightObj=(objectFacade.loadObjectBean(insightObjValue[0].getId()))

def attributes = new ArrayList<>();
attributes = insightObj.getObjectAttributeBeans();

for (def attr : attributes){
if (attr.getObjectTypeAttributeId() == "1234" ){ //id of the attribute
theStuffWeWant = attr.getObjectAttributeValueBeans();
}

log.warn( attr.getObjectAttributeValueBeans().getValue());
}

{code}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events