14266

CustomFieldManager is not getting the custom field after modifying the custom field name using REST

Question:

I'm changing the custom field name using the REST api in JIRA. It is changing the custom field name suceessfully. But when I tried to get the custom filed in the code, I'm getting null as the result.

String modByWhomCustomFieldName = pluginConfigService.getMUFCustomFieldName(); System.out.println("+++++++++++++++++++In flagCustomField() modByWhomCustomFieldName is:"+modByWhomCustomFieldName); //CustomField modByWhomCustomField = cfManager.getCustomFieldObjectByName("Description Changed By"); CustomField modByWhomCustomField = cfManager.getCustomFieldObjectByName(modByWhomCustomFieldName); if(modByWhomCustomField != null) { System.out.println("++++++++++++++ "+modByWhomCustomField.getDescription()); }

In the above it is not entering into the if conditon.

Edited from here. Whenever user changed the description of an issue, I'm displaying that user. For this I have created one custom field of type "UserCFType" . It is displaying the user who modified the description. But for user admin, it is displaying admin(admin) . I just want "admin" only not "admin(admin)".

Object modByWhomCustomFieldOldValue = issue.getCustomFieldValue(modByWhomCustomField); Object modByWhomCustomFieldNewValue = user; System.out.println("+++++++++++++++++++In flagCustomField() current user is:"+modByWhomCustomFieldNewValue.toString()); ModifiedValue<Object> modifVal2 = new ModifiedValue<>(modByWhomCustomFieldOldValue, modByWhomCustomFieldNewValue); modByWhomCustomField.updateValue(null, issue, modifVal2, changeHolder);

The above is the code for that.

Answer1:

try, getting the value. When you get the customfield object, you are getting the CF itself, not the value of that custom field at any issue. So, you get the custom field, and then the value of it for a specific issue:

cfManager.getCustomFieldObjectByName(modByWhomCustomFieldName).getValue(yourIssue)

**EDIT: For the name displaying problem, try using the getDisplayName() method on user object. Regards

Recommend

  • Yii2 model saves null values
  • PHP - Find number in a string
  • DocuSign API how to sync tags in template with Salesforce fields
  • Doctrine2 + Symfony2 Keeping history on every insert, update, delete
  • init never reaping zombie/defunct processes
  • Need to grep /etc/hosts with a known hostname, and then capture the ip address for the hostname from
  • unsupported Scan, storing driver.Value type []uint8 into type *time.Time
  • order posts by custom field
  • How to control a script is not already running?
  • CGridview custom field sortable
  • @TableGenerator not working with EclipseLink JPA 2.0
  • Error when uploading UWP app to Windows Store: Failed to merge PRI file \\Resources_split.scale-10
  • Query stays “statistics” state for long time in Google Cloud SQL (MySQL 5.5)
  • Fetching/Inserting huge chunks of data from/to a large table
  • File not found error for a QML file inside a Qt resource
  • Why can a 352GB NumPy ndarray be used on an 8GB memory macOS computer?
  • QML doesn't show svg images
  • how do you get window ID for xdotool automatically
  • How can i write equivalent sql query with join?
  • How to Get DB Field name from ConstraintViolationException - Hibernamte
  • Specifying field size of Map collection in grails DOM
  • how to swap Image in jquery
  • How to convert workspace coordinates to screen coordinates?
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • MVC3 Razor - ListBox pre-select not working
  • How to install a .deb file on a jailbroken iphone programmatically?
  • How to delay loading a property with linq to sql external mapping?
  • Recording logins for password protected directories
  • SignalR .NET Client Invoke throws an exception
  • Lost migrations and Azure database is now out of sync
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • How do I fake an specific browser client when using Java's Net library?
  • Sony Xperia Z Tablet not found by adb
  • How to get a value (ex: baseURL) in every Karate feature?
  • Validaiting emails with Net.Mail MailAddress
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?