Forums

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

Setting Elements Connect (Formerly nFeed) field in Scriptrunner Behaviour

Jordan Berry
Contributor
March 20, 2020

I am trying to prompt the user for a screen that takes in a few nFeed fields and filters them down. I would like to pre-populate a nFeed but have been unable to get it to work. Through all my googling I have not found anything yet. I am able to retrieve data from it, but not get that data back into the field. Below is the snippit of code I have been working with

import com.atlassian.jira.component.ComponentAccessor

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_18615")
def contextIssue = issueManager.getIssueObject(getContextIssueId())
def cFieldValue = contextIssue.getCustomFieldValue(cField)

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.IFieldValueService");

//def fieldValueService = ComponentAccessor.getOSGiComponentInstanceOfType(serviceClass);

//def issueKey = contextIssue.getKey();
//def customFieldId = "customfield_18615";
//def nFeedKeyValue = contextIssue.getCustomFieldValue(cField);

//fieldValueService.setFieldValue(issueKey, customFieldId, nFeedKeyValue);

import com.onresolve.jira.groovy.user.FormField;

FormField descriptionField = getFieldById("description")
FormField nFeedField = getFieldById("customfield_18615")
String[] nFeedFieldValue = (String[]) nFeedField.getFormValue()


if (getBehaviourContextId() == "x23") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)
getFieldById("project-field").setHidden(true)
getFieldById("issuetype-field").setHidden(true)

//getFieldByName("ETM Component Type").setFormValue("Frame");
//getFieldById("description").setFormValue(contextIssue.getCustomFieldValue(cField))
getFieldById("description").setFormValue(nFeedField.getFormValue())
//fieldValueService.setFieldValue(issueKey, customFieldId, nFeedKeyValue);
//nFeedField.setFormValue();
getFieldById("summary").setFormValue(contextIssue.getAssignee().getUsername()).setReadOnly(true)
getFieldById("customfield_18615").setFormValue(contextIssue.getCustomFieldValue(cField))
//getFieldById("summary").setHidden(true)
getFieldById("issuelinks-linktype").setFormValue("blocks").setReadOnly(true)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
//contextIssue.getCustomFieldValue(cField)
//contextIssue.getAssignee().getUsername();
}

1 answer

0 votes
Andra Dinu
Contributor
March 24, 2020

Hi @Jordan Berry , have you seen the Resources feature in ScriptRunner? you might be able to achieve the same result by using Resources with the Database Picker .

Best, 

Andra 

ScriptRunner Marketing

Jordan Berry
Contributor
March 24, 2020

i have not tried this yet. Does this store the selections as plain text? And when using behaviors, can I then set them the same way I would set a normal text field?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events