I want the recording, updating of change histroy and issue update event to trigger for any change in the custom fields of an issue through a single API call. Currently I am able to record, update the change histroy but issue update is not getting triggered. shown below is
1) The piece of code i have tried with
Map modifiedFields = issue.getModifiedFields();
DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder();
for (Iterator iterator = modifiedFields.keySet().iterator(); iterator.hasNext();)
{
String fieldId = (String) iterator.next();
FieldManager fieldManager = ComponentManager.getInstance().getFieldManager();
if (fieldManager.isOrderableField(fieldId))
{
OrderableField field = fieldManager.getOrderableField(fieldId);
FieldLayoutItem fieldLayoutItem;
try
{
fieldLayoutItem = ComponentManager.getInstance().getFieldLayoutManager().
getFieldLayout(issue.getGenericValue()).getFieldLayoutItem(field);
final ModifiedValue modifiedValue = (ModifiedValue) modifiedFields.get(fieldId);
field.updateValue(fieldLayoutItem, issue, modifiedValue, issueChangeHolder);
}
catch (FieldLayoutStorageException e)
{
// TODO Auto-generated catch block
}
}
}
2) other piece of code I tried is
public void updateIssue(MutableIssue issueObject, OperationContext operationContext, User user, ErrorCollection errors, I18nHelper i18n)
throws RemoteException
{
try
{
webwork.dispatcher.ActionResult aResult = updateFieldsHelperBean.updateIssue(issueObject, operationContext, user, errors, i18n);
ActionUtils.checkForErrors(aResult);
}
catch(Throwable e)
{
log.error((new StringBuilder()).append("Exception occurred editing issue: ").append(e).toString(), e);
throw new RemoteException((new StringBuilder()).append("Error occurred editing issue: ").append(errors.getErrors()).append(" ").append(errors.getErrorMessages()).toString(), e);
}
}
Hi Nic,
On behalf of sanjeev, i am relplying back to you.
No it's neither run under post-function nor listener. We have developed a tool which imports data available in excel file and the code is run under Import functionality. Re-indexing(indexing) is happening properly. Presently to trigger the Issue update event we are calling the below code
public void fn_TriggerIssueUpdateEvent(MutableIssue issue)
{
HashMap params = new HashMap();
params.put("baseurl", ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL));
//prevent a mail from being generated
params.put("dispatchEvent", new Boolean(false));
Long evtTypeId=Long.valueOf(2);
EventType event = ComponentManager.getInstance().getEventTypeManager().getEventType( evtTypeId );
IssueEvent issueEvent = new IssueEvent( issue, params, u, event.getId() );
IssueEventDispatcher.dispatchEvent( issueEvent );
}
We want to avoid calling the above function every time the custom field is updated and hence are looking for an alternative.
Best regards
Sanjeev
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where is this being run? Post-function, listener? etc?
Also, is it indexing ok? (This is nothing to do with the event, but it's worth checking)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No it's neither run under post-function nor listener. We have developed a tool which imports data available in excel file and the code is run under Import functionality. Re-indexing(indexing) is happening properly. Presently to trigger the Issue update event we are calling the below code
public void fn_TriggerIssueUpdateEvent(MutableIssue issue)
{
HashMap params = new HashMap();
params.put("baseurl", ManagerFactory.getApplicationProperties().getString(APKeys.JIRA_BASEURL));
//prevent a mail from being generated
params.put("dispatchEvent", new Boolean(false));
Long evtTypeId=Long.valueOf(2);
EventType event = ComponentManager.getInstance().getEventTypeManager().getEventType( evtTypeId );
IssueEvent issueEvent = new IssueEvent( issue, params, u, event.getId() );
IssueEventDispatcher.dispatchEvent( issueEvent );
}
We want to avoid calling the above function every time the custom field is updated and hence are looking for an alternative.
Best regards
Sanjeev
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.