Skip to main content
March 3, 2016
Answered

Delete Attachement/Annotation based on description

  • March 3, 2016
  • 1 reply
  • 1168 views

I have two button to attached two different files and have coded it to show a specific description when viewing the properties. For this example lets say one is "dog" the other is "cat".

so that the end user does not have to go to the attachment pan and manually delete the file, I need a script that will only delete the file type with a description of "cat".

FYI Background.

Ap: Adobe Pro XI, I do not have Livecycle

I am already using a reset button to wipe the whole form, which works great. I have already coded that if a user selects an item from a drop down box, it makes the "cat" attachment button available, however if the user for what ever reason changes the drop down selection after attaching the "cat" file, the attachment remains and does not delete.  Since attachments are annotations versus object, what would be the script to just recognize if the file description is "cat", remove it - Then I will add it to my drop down box script.

Thanks!

This topic has been closed for replies.
Correct answer George_Johnson

So you must also have code that removes all attached files. You'd just have to modify it a bit so it looks at either the name or contents property and only removes those that indicate cat.

1 reply

Inspiring
March 3, 2016

Exactly how are users attaching the files? If you're using a script in the cat and dog buttons, it would be helpful to see the scripts.

March 3, 2016

Thanks for replying George.  I am using 2 document level scripts provided in another discussion.  I need two because I need the description of each file to be unique regardless of the name the user attaches.  But I want the drop down box, lets call it "animal type" to control if the Cat attachment stays or goes.  The Dog Attachment should always remain until the user resets the whole form.  (no issues there it works).

function attach_11() {

try {

  var annot = addAnnot({
   page: event.target.page,
   type: "FileAttachment",
   author: "Submitter",
   name: "CAT",
   point: [oFAP.x, oFAP.y],
   contents: "CAT: ",
   attachIcon: "Paperclip"
  });

  annot.cAttachmentPath; // Prompt user to select a file to attach
 
 
} catch (e) {

  app.alert({
   cMsg: "No File Attached.\r\r",
   cTitle: "File attachment error",
   nIcon: 3,
   nType: 0
  });

}

}

George_JohnsonCorrect answer
Inspiring
March 3, 2016

So you must also have code that removes all attached files. You'd just have to modify it a bit so it looks at either the name or contents property and only removes those that indicate cat.