Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Clone item if request type matches

Ana Luiza Chagas May 22, 2024

Hi Team!

My team and I are using a post function scriptrunner for jira cloud to clone items for other projects.

We are faced with a scenario in which cloning of items should only be done if the type of request (customfield_10010) is the same or different from that informed.

I've already tested both ways within the post function as shown in the image below, but without success.

condition.PNG

This happens even when opening tickets corresponding to the type of request informed in the ID.

Has anyone seen anything like this? Can you help me?

Thanks!

1 comment

Sean Chua _Adaptavist_
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.
May 23, 2024

Hey @Ana Luiza Chagas ,

It looks like you are trying to ensure the condition is set to JSM's request type. Have you tried using it with the name? 

eg: 

issue.customfield_10010?.requestType?.name == 'Create Ticket'
That seems to work for me :) 
Hope that helps,
Sean
Ana Luiza Chagas May 23, 2024

Hi @Sean Chua _Adaptavist_ 

I tested the solution you suggested in your comment, but in all cases (even with the ticket being the same type of request that I indicated by name) the log reports that there are no matches and therefore the flow does not work as expected.

I followed this: issue.customfield_10010?.requestType?.name == 'New user'

Thanks

Sean Chua _Adaptavist_
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.
May 23, 2024

Hi @Ana Luiza Chagas ,

Did a check with my Jira Cloud instance to test the Built-in Clone Issue again. Try using this:

issue.fields.customfield_10010.requestType.name == "New user"

I set mine up as a Post Function when I transition to "Done". It successfully cloned general details within the same project, and then tried it to another JSM project - both works. I would assume that it should work with any other project as well to clone the general default field details. If you need to fill up fields and/or other specific details, you can add the code at the bottom console for "Additional Code".

Here is the workflow set up:

image.png

And this is the ticket which was cloned/created in the other project and linked back to original ticket:image.png

Hope that helps

Like Ana Luiza Chagas likes this
Ana Luiza Chagas May 27, 2024

Hi @Sean Chua _Adaptavist_ 

Thank you very much for the solution. Now the function worked in my project and worked as expected!

One question, if there are more scenarios like this, could you indicate how in this example below? 

issue.fields.customfield_10010.requestType.name == ("New user", "New account")

Thanks!

imadero May 28, 2024

The solution will be 

["New user", "New account"].includes(issue.fields.customfield_10010.requestType.name)

 

Thanks, Ivan.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events