Forums

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

How to set value to custom field (Elements Connect (nFeed) custom field) using [Script Runner]?

Juhaina Almama
Contributor
April 5, 2020

Hi!

I am using Script Runner post function in order to clone issue from JSD project til business project (Clones an issue, and links).

I have custom field in the target project having the type Elements Connect (nFeed) custom field.

I want to set value 'CUSTOMERQUERY' to the created issue.

I am trying the script 


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

def fieldValueService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

def issueKey= issue.getId().toString()
def customFieldId = "customfield_17005";
def nFeedKeyValue = "CUSTOMERQUERY";

fieldValueService.setFieldValue(issueKey, customFieldId, nFeedKeyValue);

but I get error ' Cannot finding the matching method'

can any one help me to write the script?

3 answers

2 accepted

1 vote
Answer accepted
Simon Laffont
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.
April 6, 2020

Hi @Juhaina Almama ,

I'm on the Elements Support Team.

Even if an error appears in the console, your script is still supposed to work. I have just tested it and it works for me.

You just have to make sure you entered a valid key and nothing else:Make sure the nFeedKeyValue is a key.png

Concerning the error message, I am afraid we can't do anything for you to fix that. Indeed, the syntax validation feature doesn't check external classes that are added within the script, because it's loaded on runtime. 

In addition, you will find on the following link our documentation showing some examples of the use of Elements Connect fields in Scriptrunner: https://doc.elements-apps.com/elements-connect/latest/api-guide/java-api/scriptrunner-use-elements-connect-api-in-a-script

Have a nice day.

Kind regards,
Simon.

Juhaina Almama
Contributor
April 6, 2020

Thank you Simon, it was nFeedkeyvalue problem since I used value and not the key.

Simon Laffont
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.
April 7, 2020

My pleasure. :)

NOGenie
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 14, 2020

Hi @Simon Laffont , 

How do I get the other values from the query results using ScriptRunner post function? I've only been able to get the key and the display value. 

 

Thanks,

Nkem

1 vote
Answer accepted
Simon Laffont
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.
April 6, 2020

Hi @Juhaina Almama,

I'm on the Elements Support Team. 

Even if an error appears in the console, your script is still supposed to work. I have just tested it and it works for me.*

You just need to make sure you entered a valid key and nothing else:

Make sure the nFeedKeyValue is a key.png

Concerning the error message, I'm afraid we can't do anything for you to fix that. Indeed, that's more a ticket for Adaptavist, the editor of ScriptRunner. Their syntax validation feature doesn't check external classes that are added within the script, because it's loaded on runtime. Thank you for your understanding.

In addition, here is documentation showing some examples of the use of Elements Connect fields in Scriptrunner: https://doc.elements-apps.com/elements-connect/latest/api-guide/java-api/scriptrunner-use-elements-connect-api-in-a-script

Have a nice day.

Kind regards,
Simon.

0 votes
Ed Gaile _Atlanta_ GA_
Community Champion
April 5, 2020
Juhaina Almama
Contributor
April 5, 2020

Thanks for your replay , this exactly what I did, but it is not work , can you help? ,I am new i writing script :(

Juhaina Almama
Contributor
April 5, 2020

CaptureERR.PNG

Suggest an answer

Log in or Sign up to answer