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

get the value of an Elements connect field in Scriptrunner scripted field

I want to create a scripted field that has its value set based on the contents of a elements connect field.  So far I have been working in the scriptrunner console just trying to get the value of the field and it keeps returning null.  The Elements connect field is a snapshot field that reads an Active directory value.  I have verified the value is set on the field so it isn't null.  

Here is the code I have so far.

import com.atlassian.jira.component.ComponentAccessor

def pluginAccessor = ComponentAccessor.getPluginAccessor();
def plugin = pluginAccessor.getPlugin("com.valiantys.jira.plugins.SQLFeed");
def serviceClass = plugin.getClassLoader().loadClass("com.valiantys.nfeed.api.IFieldDisplayService");

def fieldDisplayService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

def issueKey = "Issuekey-123458";
def customFieldId = "customfield_12633";

String displayValue = "";
Object displayResult = fieldDisplayService.getDisplayResult(issueKey, customFieldId);
if (displayResult != null) {
displayValue = displayResult.getDisplay();
}
return displayValue;

 Anybody have an idea how I can get this to work.  The long term goal of this field will be to compare the approvers title to a list of titles we use to stop the approval process.  We are currently using a regular expression in several automation's to compare the titles and I want to consolidate where we are doing this process to one location so when a persons title change we don't have to update multiple automation condition checks.

2 answers

0 votes

Hi,

with your function from the docs you will get the display value. Have you configured your display view? You can try it in the Field Configuration.

Have you tried to get the key value instead of the display value?

Under Read Field Key:

https://doc.elements-apps.com/elements-connect/latest/api-guide/java-api/scriptrunner-use-elements-connect-api-in-a-script

Hi @Dan Wolff

I'm Nicolas from Elements, vendor of Elements Connect.

If you get a "null" result with this piece of code, that means there are 3 possible explanations:
- "customfield_12633" is not a valid reference
- "Issuekey-123458" is not a valid issue key
- field is empty in the given issue

Here is an example with a Scripted Field:

2020-08-05 10_25_16-Window.png

Can you please try again by checking all these points?

If you still have issues, please open a support ticket from this portal: https://support.elements-apps.com/portal

Thank you.

Kind regards,
Nicolas.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Announcing the winners of Codegeist 2020

Hey team! We brought back Codegeist in a big way this year, and today, we’re thrilled to announce the winners. 🎉 Thank you to everyone who participated in Codegeist 2020. This year, we go...

247 views 5 13
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