Condition for making no of Attachment mandatory in a specific transition in workflow.

siva February 16, 2020

Is there any optional script that can be used to make 

 

4 attachments mandatory at a specific transition in workflow of jira.

 

 

 

 

1 answer

0 votes
Will C
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 17, 2020

Use a simple scripted condition in a workflow post functions using scriptrunner and use the following code:

import com.atlassian.jira.component.ComponentAccessor
ComponentAccessor.attachmentManager.getAttachments(issue).size() >= 4

I am presuming this is what you want? this won't let you transition the issue unless there are 4 or more attachments attached to the current issue. 

siva February 17, 2020

@Will C  thank you

 

I had the Script for 4 or greater in an issue.

is there any option at a specific transition i 4 attachments ??

Will C
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 17, 2020

Sorry I don't understand your question? so you know there is 4 attachments at a specific transition in the workflow, what are you want to do now?

Daniel Ebers
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 17, 2020

Starting off here you could do some further actions based on ScriptRunner (please see here for further documentation: https://scriptrunner.adaptavist.com/5.6.15/jira/recipes/workflow/validators/validate-attachments-links-in-transition.html).

Cheers,
Daniel

siva February 17, 2020

sorry ill elaborate, 

when i make a transition, i have a pop up screen which requests for a attachment.

at that point i need to make a validator scritpt that if user doesnt attach 4 attachments.

 

the transition gives an error.

Will C
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 17, 2020

I understand what you want to do now, I am not sure if the pop up part of this is possible. it is possible to check for attachments and then put an error against a field when this isn't met, but the part with a pop up I am not sure of, maybe somebody from Adaptavist will be able to advise further.

Like siva likes this
Manoj September 7, 2022

@Will C 

@Daniel Ebers 

Hello Both, Greetings!

is there any way to make attachment based on condition and moves the transition.

like i have a custom field is "Total Amount" 

If the total Amount is >= 10000 then attachment is mandatory to attach.

and IF the total amount is <10000 then attachment is not required. 

Kindly advice.

Suggest an answer

Log in or Sign up to answer