How to use Scriptrunner "fire event when condition is true" on a non cloned issue ?

Laurent Bierge
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.
April 21, 2017

Hi,

I'm totally new to scriptrunner and i would like to use it for a specific purpose.

When i create an issue i want "Issue created" event to be triggered (default behaviour) but when on the same project, an issue is cloned i don't want to trigger the "Issue created" event.

I'm pretty sure that i can do it with the Scriptrunner - "Fire event when condition is true" but i can't see how. I've been through the scriptrunner website and found "hasLinkType" but since it's a JQL function it seems that i can't use it in a simple script.

Mostly the condition i want is :

!(issueFunction in hasLinkType("Cloners"))

that would return true if the issue has no Cloners Link.

I've also look into the API, but i'm completly lost. I wanted to find something like issue.linkName to put issue.linkName == Cloners. But i don't find the Instance variables of "issue" which is bothering me.. There is some example like "issue.priority?.name, issueType.name,.." but i don't manage to find those instance variables

If anyone has a simple solution for what i want to do, or know how to find those instance variables i would be very gratefull !

Regards,

Laurent

2 answers

1 accepted

0 votes
Answer accepted
Laurent Bierge
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.
April 28, 2017

Well ! If anyone is interested.

I found a solution.

Actually the function getOutwardLinks() didn't work, the result was always empty. I think, it's because the issue is not fully indexed just after the creation (before the transition to the first status).

To detect that an issue was a Clone, i passed by the summary. To be precise, i used:

issue.summary.contains('CLONE').

The statement is that the user will not change the name of the clone while Cloning it.

However, i didn't find how to delete the fourth event (which is useless in this case)

0 votes
adammarkham
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.
April 25, 2017

If you are cloning an issue to the same project, I assume you don't want to fire the event because you get stuck in a loop where the issue keeps being cloned?

The create issue event is published by JIRA and there is no mechanism to prevent it.

The clone issue script is mainly to clone to another project. Is there a reason that you want it in the same project?

Laurent Bierge
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.
April 25, 2017

Hi !

Actually i don't want to clone it on the same project but it seems to be an unavoidable step. The main idea is to aboid to trigger the "issue created" event, to avoid to send mail when the issue created is a clone.

When i clone an issue, i can only select the name of the issue before validate it. If you have another way to clone the issue on another project without moving the source issue before, i'm very interested !

However, the way i see it, it should be possible to do exactly what i say.

In attachment i'll put something that don't work, but that represente the main idea of what i want. The event "DEVIS EN COURS" is an event that doesn't send mail. Besides, those post functions are on the first transition, between the start of the workflow and the first state "To do".

Regards,Post functions.PNG

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events