Hi.
I have developed a plugin with a listener which is able to catch the events fired in JIRA.
I want when special events are fired, to read the values of specific fields of a screen and pass them to an external database.
I haven't found any documentation about how I could the read the values from the fields of a screen.
Can you guide what classes I could use for this ?
Thanks for your help.
Dimitris
Hi, you can use change items to detect fields.
try { // Read change items, comment List<GenericValue> changeItems = event.getChangeLog().getRelated("ChildChangeItem"); Comment comment = event.getComment(); String field, fieldType; for (GenericValue changeItem : changeItems) { fieldType = (String) changeItem.get("fieldtype"); field = (String) changeItem.get("field"); // Field Name // Collection of all fields with the same name! Collection<CustomField> cfCol = Helper.getCustomFieldByName(field); // ... // Detect attachment if (Constants.CHANGE_ITEM_FIELD_TYPE_JIRA.equalsIgnoreCase(fieldType) && // JIRA Constants.CHANGE_ITEM_FIELD_ATTACHMENT.equalsIgnoreCase(field)) { // Attachment Object attachmentId = changeItem.get("newvalue"); if (attachmentId != null && attachmentId.toString().length()>0) { // Attachment Add try { Attachment attachment = ComponentAccessor .getAttachmentManager().getAttachment(Long.valueOf(attachmentId.toString())); // Action } catch (DataAccessException dae) { error("Unable to access attachment with id:" + attachmentId.toString() + "!", dae); } } else { // Attachment Delete, no WS interface method attachmentId = changeItem.get("oldvalue"); debug("Attachment with id:" + attachmentId.toString() + " delete action is not sychronized."); } } else { // Read value from changed field + operation } } } catch (GenericEntityException gee) { log.error("Can not read change items list!", gee); }
Hi.
Thanks for your response.
The problem with the solution you describe is that I catch only the fields with changed content. What I want to do is to develop a workflow where the at the first step the issue creator will fill a screen with data. At the final step of the workflow, before the case is closed, I want my listener to be able to read the data from the screen and store them to a external database. The data of the screen may be the same with data that the issue creator filled at first step of the workflow.
Dimitris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you need post function (not the listener) and add this function into the last workflow step. Function wiil be read issue content and call methods to update external DB.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.