Hello Community,
I am stuck on this problem since last one week. I am actually creating one addon using Java and Maven which will help me in integrating jira with some other third party tool.
What I want to do is to capture the current values of the fields on the particular issue and pass them to the other tool using webservices. Capturing the same works well for jira default fields but for custom fields nothing seems to be happening. The value always comes out to be null. Following is the snapshot of the code that I have written,
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean {
private final EventPublisher eventPublisher;
public String field = null;
public String fromValue = null;
public String toValue = null;
public String user = null;
public String issueType = null;
public String jiraId = null;
public String silo=null;
public IssueCreatedResolvedListener(EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
@Override
public void afterPropertiesSet() throws Exception {
// register ourselves with the EventPublisher
eventPublisher.register(this);
}
@Override
public void destroy() throws Exception {
// unregister ourselves with the EventPublisher
eventPublisher.unregister(this);
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent) throws IOException {
Issue issue = issueEvent.getIssue();
CustomField cf=ComponentAccessor.getCustomFieldManager().getCustomFieldObject((long) 14440);
silo=cf.getValueFromIssue(issue);
}
In the above code the field silo is a custom field in our instance and 14440 is the ID of the same. But this value always comes null.
Can you please suggest where I am making any mistakes? Your help would be highly appreciated. Thanks in advance :) :)
Some custom fields may not store a value in the database, mostly fields of third-party plugins.
What is the type of field that you're looking for?
If you can navigate database, please check that table `customfieldvalue` has a value for your field and your issue.
Hi Mikhail,
I have checked in the database and found that there is no value for my desired customfield and issue in Customfieldvalue table.
This customefield is of type com.atlassian.jira.issue.customfields.impl.RenderableTextCFType@225871e1
Can you please suggest how can I get that value?
Is there any way?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Try like this:
silo = issue.getCustomFieldValue(cf).toString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alexey,
Thanks for the reply but this also gave null value :( :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.