Hi,
I want to get all the default values populated for the FIELD using JIRA API.
For Ex : FixVersion is a select field which may populates some default values in its "Select" dropdown llist. I want to retrive all those values populated in that dropdown list.
I want to know how to find out those "Fields" which populates predefined values and values of those Feilds using Jira API.
Can any one please suggest solution or share some sample code for this.
Thanks in Advance,
Satya.
Community moderators have prevented the ability to post new answers.
Collection<Version> versions = versionManager.getVersions(project.getId()); Collection<Version> versions = versionManager.getAllVersions(); Collection<Priority> priorities = constantsManager.getPriorityObjects();
And so on :-)
Hi Mizan,
def componentManager = ComponentManager.instance def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) def customFieldManager = componentManager.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("SelectListA") def fieldConfig = cf.getRelevantConfig(issue) def option = optionsManager.getOptions(fieldConfig).find {it.value == "BBB"}
In the above code, what Does it mean if "fieldConfig" returns me NULL.
Regards,
Satya
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.
What are you trying to do ? can you explain the scenario ? why you need the options of a field ?
Do you need the options or the default value selected in the field when you create aissue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually I want to create Issues in Jira by using Jira API , for this i get all the required information like projectName and all the field names issueTpe, Summary, Priority, Fixversion .. etc.. and its values as my Input data/Source data.
So before creating the issue I need to validate my source data whether it has Desired Field values to create the Issue or not.
For Ex: Let us assume that i have a select filed called "Country" and it has predefined values as 'India', 'USA', 'UK' populated in its Dropdown list.
Here I need to ensure that My source data should only contain any one of the above mentioned values (ie., 'India', 'USA', 'UK') for the Filed "Country".
Regards,
Satya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have this groovy code , had found it on answers . you will have to convert it to Java because the .find is not available in Java . You will have to iterate through the options and check if the value is present or not
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.customfields.manager.OptionsManager def componentManager = ComponentManager.instance def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) def customFieldManager = componentManager.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("SelectListA") def fieldConfig = cf.getRelevantConfig(issue) def option = optionsManager.getOptions(fieldConfig).find {it.value == "BBB"} issue.setCustomFieldValue(cf, option)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
def componentManager = ComponentManager.instance def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) def customFieldManager = componentManager.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("SelectListA") def fieldConfig = cf.getRelevantConfig(issue) def option = optionsManager.getOptions(fieldConfig).find {it.value == "BBB"}
In the above code, what Does it mean if "fieldConfig" returns me NULL.
Regards,
Satya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
AFAIK there is nothing that will give you a list of all fields which have predefined values. You need to know which field(s) you are interested in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I said: it depends on the field. The values aren't necessarily tied to the field - to use your example of earlier, the values displayed in the FixVersions field are nothing to do with the field itself; they come from the VersionManager.
Most of the other built-in fields - IssueType, Priority, Status, Resolution, etc - get their values from the ConstantsManager. For a custom field you need to get the CustomField object and call its getOptions() method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay .. Thnx Alex ..
But asking with Curiosity .. Is there any other way /API-method which takes my Project and Field names as input and gives me the values of that particular field ..
Regards,
Satya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No. Fields are not tied to Projects - their predefined values are global.
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.
Thnx Alex for your response..
But what my requirement here is to get all the defult populated values of the FIELDs.
For Ex : FixVersion is a select field which may populates some default values in its "Select" dropdown llist. I want to retrive all those values populated in that dropdown list.
Thanks & Regards,
Satya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, sorry, I misunderstood your question.
It depends on the field - for FixVersions you need to look up the list of Versions for either a specific project or the entire system. VersionManager.getAllVersions() or VersionManager.getVersions(projectId) will do this for you:
There are similar APIs for IssueType, Component, Status and so on.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's Ok Alex..Thanks once again ..
I just mentioned the "FIxVersion" as an example for those kind of filelds, like that in JIRA we have so many filelds which poplulated predefined values populated .
So i want to get all the values of those kind of Fields.
So here i know the Project Name, and IssueType's associlated with this project and Fields associated with each of these IssyeTypes.
Now out of above list of Fields I want to get the Field names which populates predefined values and then need to find out the values of those Feilds .
Regards,
Satya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.