Hi all,
We are working in a JIRA replication project, where two remote instances should be continously synchronized.
Then, I need to set a nFeed customfield in a post-function using a Groovy code.
I am using a code like this, but does not work, raising the error below:
customerValue = "ABC CONS MET ASSES E MERC S/A - SAO PAULO - BRAZIL" //Sample value cfCustomer = customFieldManager.getCustomFieldObject(10601) //nFeed Customer field cfCustomer.updateValue(null, missue, new ModifiedValue(null, customerValue ), new DefaultIssueChangeHolder())
The error raised is:
2013-03-06 09:15:30,744 http-bio-9081-exec-9 ERROR 2208.1 555x25241x1 i8yokm 200.150.176.119,127.0.0.1 /secure/QuickCreateIssue.jspa [plugins.sql.customfield.SQLFeedCustomFieldType] Unexpected value 'ABC CONS MET ASSES E MERC S/A - SAO PAULO - BRAZIL'
2013-03-06 09:15:30,745 http-bio-9081-exec-9 ERROR 2208.1 555x25241x1 i8yokm 200.150.176.119,127.0.0.1 /secure/QuickCreateIssue.jspa [plugins.sql.customfield.SQLFeedCustomFieldType] Invalid data type 'ABC CONS MET ASSES E MERC S/A - SAO PAULO - BRAZIL' while creating changelog string
I think this very strange, since this value is exactly the same used where the field is showed in the issue view.
We tried use the primary key in the "customerValue" (like 1234), but the error remains.
There are some documentation or tip about this issue ?
Hi all, with support of Valiantys (https://jira.valiantys.com/browse/SQLFEED-521) the solution is:
customerValue = "ABC CONS MET ASSES E MERC S/A - SAO PAULO - BRAZIL" //Sample value cfCustomer = customFieldManager.getCustomFieldObject(10601) //nFeed Customer field nFeedContent = missue.getCustomFieldValue(cfCustomer) nFeedContent.clear() nFeedContent.add(customerValue) cfCustomer.updateValue(null, missue, new ModifiedValue(null, customerValue ), new DefaultIssueChangeHolder())
Hello,
Here is a most updated answer:
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 =
"ISSUE-12345"
;
def
customFieldId =
"customfield_12345"
;
def
nFeedKeyValue =
"10001"
;
fieldValueService.setFieldValue(issueKey, customFieldId, nFeedKeyValue);
(i) If you need to read a value from an nFeed field, you can use the "getFieldValues(issueKey, customFieldId)" function from the same service.
Sources:
Kind regards,
Nicolas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nicolas,
If we want to get nFeedKeyValue programatically ,can we use getFieldValues(issueKey, customFieldId) method?
If so can we pass that value into setFieldValue method as a part of nfeedkeyvalue parameter?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vineela,
Yes, you can use the getFieldValues function to get the Key of an nFeed custom field, against one of your issue.
For the second question, let me do a quick reminder of the service:
public
interface
IFieldValueService {
void
setFieldValue(String issueKey, String customFieldId, Object fieldValue);
void
setFieldValues(String issueKey, String customFieldId, Collection<?> fieldValues);
Collection<?> getFieldValues(String issueKey, String customFieldId);
}
As you can see, the getFieldValues function returns a Collection. So, if you want to use it as Key for another nFeed custom field, make sure your fields is a multiple values. The function to use in this case is: setFieldValues
Otherwise, you should use the other function, setFieldValue, and you need to extract the value from your Collection before, in order to pass it as a parameter.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nicolas
So is my below syntax correct?
Collection<?> collection=fieldValueService.getFieldValues(issue.getKey(),plannedrelos.getId())
Now I should be extracting the values from this collection rite?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also when I try to pass this collection in setFieldvalues
fieldValueService.setFieldValue(issue.key,plannedrelos.getId(),coll
nothing is being set on nfeed field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As answered in the support ticket:
import com.atlassian.jira.component.ComponentAccessor import org.apache.log4j.Category Category log = log log.setLevel(org.apache.log4j.Level.DEBUG) def issueService = ComponentAccessor.getIssueService() def issueManager = ComponentAccessor.getIssueManager() def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.setSummary("TEST TEST") issueInputParameters.setProjectId(10000L) issueInputParameters.setIssueTypeId("10100") issueInputParameters.setReporterId("valiantys") def mySourceIssue = issueManager.getIssueObject("TEST-5") def myField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10203") def values = mySourceIssue.getCustomFieldValue(myField) def String[] myArgs = new String[values.size()] for (int i = 0; i < values.size(); i++) { myArgs[i] = values[i] } issueInputParameters.addCustomFieldValue((Long) 10203, myArgs) def createValidationResult = issueService.validateCreate(loggedInUser, issueInputParameters) if (createValidationResult.isValid()) { def createResult = issueService.create(loggedInUser, createValidationResult) }else{ log.debug("KO") }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How would one do this if there is no issue key.
i.e. when creating an issue and using the field in a scriptrunner field behavior?
def modifiedList = ['a', 'b']
getFieldByName("My List of Options").setFormValue(modifiedList)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.