How can i detect if an attachment has been deleted ?

Anya CHOUKRANE March 10, 2021

Hello everyone, 

I am working on listeners in order to control who can add and delete attachments. I was able to do it for the adding part by using this code on my listener.

List changeItems = event.getChangeLog()?.getRelated("ChildChangeItem")
                    changeItems.each {GenericValue gv ->
                        if (gv["field"] == "Attachment" && gv["newvalue"]) {
                            attachmentIds.add(gv["newvalue"])
                        }
                    }

 But for the deleted attachment part i have no idea. How can i detect if an attachment has been deleted ? 

Thank you in advance.

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 10, 2021

Hello @Anya CHOUKRANE 

Welcome to the community.

The ability to create and delete attachments can be managed through the Permission Scheme associated with a project, for Classic projects at least. Is there a reason that methodology doesn't work for your scenario?

Anya CHOUKRANE March 11, 2021

Hello, thank you for your response.

 

My goal is to restrict the permission of adding/deleting attachments based on a custom field value. This is not possible to do from the administration menu. I was able to do it for the adding part (i created a listener on "Issue update"  that automatically deletes an added attachment if the condition with the custom field is not met).

I want now to restrict who can delete attachment based on the same custom field value.

 

Thank you

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events