update custom field of issue with predefined values

TW April 2, 2015

Hi,

i got an issue custom field (selectable values:   A, B, C ord D) --> only one selectable.

 

  1. How can i read possible values with JRJC?
  2. How do i set such a value?

6 answers

0 votes
TW April 20, 2015

hi is it possible to get all possible values of a custom field without iterating through all projects?

just like this:

CimProject p = new CimProject("MYKEY");

...

 

0 votes
Arun_Thundyill_Saseendran
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 14, 2015

For this you have parse the versions object.

Inside the versions object there will be a value called as 'archived'. If it is set to true then it is an archived version. Else it is not archived.

0 votes
TW April 14, 2015

thanks a lot. It works - specially for CustomFields with a SingleVersionPicker too.

 

But how do i get only Versions, which are not archived?

0 votes
Arun_Thundyill_Saseendran
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 13, 2015

If you know the field ID, then pull an issue from that project using GET REST for issue. In the expand parameter specify 'editmeta'. JIRA will give you all the possible values for all select fields and even cascade fields.

0 votes
TW April 2, 2015

thanks, i think you mean this one:

 

for (Map.Entry<String, CimFieldInfo> entry : issueType.getFields().entrySet()) {
			final CimFieldInfo fieldInfo = entry.getValue();
			final String fieldCustomType = fieldInfo.getSchema().getCustom();
			final String fieldType = fieldInfo.getSchema().getType();
			final String fieldId = fieldInfo.getId();

			if ("project".equals(fieldId) || "issuetype".equals(fieldId)) {
				// this field was already set by IssueInputBuilder constructor - skip it
				continue;
			}

			log.log(MessageFormat.format("\t* [{0}] {1}\n\t\t| schema: {2}\n\t\t| required: {3}", fieldId, fieldInfo
					.getName(), fieldInfo.getSchema(), fieldInfo.isRequired()));

			// choose value for this field
			Object value = null;
			final Iterable<Object> allowedValues = fieldInfo.getAllowedValues();
			if (allowedValues != null) {
				log.log("\t\t| field only accepts those values:");
				for (Object val : allowedValues) {
					log.log("\t\t\t* " + val);
				}

 

 

but how do i get all possible values for a special field? (i know the field id)

Piotr Swiecicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 2, 2015

it's higher up in the same method. issueType.getFields().entrySet() - gives map of all the field types. Values are of CimFieldInfo type, you can call getAllowedValues() method to get available values.

0 votes
Piotr Swiecicki
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 2, 2015

Suggest an answer

Log in or Sign up to answer