How to pass params when using IssueManager.updateIssue

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 8, 2018

I am updating an issue (Issue B) from the update event handler of another issue (Issue A). I am also going to be handling the resulting update event of Issue B in another event handler.

Below is the code to do the update on Issue A:

issueManager.updateIssue(user, targetIssue, EventDispatchOption.ISSUE_UPDATED, false);

How can I add params to the resulting event so I can get those param values from IssueEvent object while handling the update event on Issue B.

1 answer

0 votes
Alexey Matveev
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.
February 8, 2018

I do not think you can add something to an event. Why you can not do everything you need in the listener for Issue A?

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 8, 2018

The question I asked explains the requirement in an oversimplified fashion. To give a little more detail I can say that Issue A will update not only Issue B but potentially update a number of issues and each issue might respond with the update of a number of other issues as well. The event mechanism is the perfect fit for propogating the updates.

And also, firing an event ensures that any other plugin in the system listening to updates on issues respond to the update too.

The IssueEvent object (which is a parameter we get in an event handler) has a "params" map<String, Object> attached to it. The map feels like it is intended to carry arbitrary data with the event so I am searching for a way to insert data into that params map.

Alexey Matveev
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.
February 8, 2018

Maybe it could work like this

Issue updatedIssue = issueManager.updateIssue(user, issue, UpdateIssueRequest.builder()
.eventDispatchOption(EventDispatchOption.ISSUE_UPDATED)
.sendMail(false)
.issueProperties(new HashMap<>())
.build());

 But I did not try it.

Emre Toptancı _OBSS_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
February 9, 2018

With a little bir of tweaking I got it to work. I can successfully dispatch an event and catch it in the other end.

HashMap<String, JsonNode> params = new HashMap<>();
params.put("myKey", new TextNode("myValue"));
Issue updatedIssue = issueManager.updateIssue(updater, targetIssue, UpdateIssueRequest.builder()
.eventDispatchOption(EventDispatchOption.ISSUE_UPDATED)
.sendMail(false)
.issueProperties(params)
.build());

Unfortunately params do not contain the values I provide. It just looks like a regular IssueEvent object.

I guess I will need to find a way to do manual recursion.

Suggest an answer

Log in or Sign up to answer