How to differentiate between creating issue via rest versus creating issue via clone

Dan27 December 13, 2020

Hello,

 

I have a script in workflow 'issue create' that checks if issue created manually or by clone:

def request = ActionContext.getRequest()
if (request)

{ log.warn "The issue created manually" return }

//clone issue
else

{ log.warn "The issue came from a clone action" }

I figured that if issue created by REST, the script returns 'null' like issue clone,
and I have to seperate those two option for creation.

How can I differentiate between creating issue via rest versus creating issue via clone using groovy script?

We would like do delete some copied field's values when the user clone an issue.
In REST issue we dont want to delete these fields's values.

 

Thank you,
Daniel

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2020

Hi @Dan27 , I do not think it is possible to check the way the issue was created in create transition.

But what about to try to use logic which will contain the rule that cloned issue is always linked with source issue with specific type of link by default? So you can

  1. implement listener to issue created event
  2. check the links on the created issue
  3. clear values if link of specific type is created on the issue
Dan27 December 13, 2020

Hi @Martin Bayer _MoroSystems_ s_r_o__ ,

Thank you for your answer.

In issue created event listener, you can't find the links of the issue yet, I already tried it..

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2020

hm ok @Dan27 so what about to use https://docs.atlassian.com/software/jira/docs/api/7.6.0/com/atlassian/jira/event/issue/link/IssueLinkCreatedEvent.html?

I think clones link is not created manually often so it may be the basic filter...or you Can add check that for example timespan between issue was created and link was created is lower than 5s...

Dan27 December 15, 2020

Thanks @Martin Bayer _MoroSystems_ s_r_o__ ,

It has the same problem, in issue creation, the link didn't exists...

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 15, 2020

Hi @Dan27 you have all needed information in IssueLinkCreatedEvent object. You can get issue link using getIssueLink() method and it contains sourceObjectdestinationObject and issueLinkType (https://docs.atlassian.com/software/jira/docs/api/7.6.0/com/atlassian/jira/issue/link/IssueLink.html)

Suggest an answer

Log in or Sign up to answer