Delete Attachment Assistance
Greetings –
I am looking for a way to delete files added to a form using the below script I obtained from a forum. Wish I could remember which forum so I could give proper kudos; as the below works perfectly allowing me to attach any type of file to the form.
What I need now is a way to delete these files? Have been unable to locate anything on how to delete a file, attached in the manner below. Anyone have any ideas?
Thanks in advance for your time. Any assistance will be greatly appreciated.
Script to attach file(s) - (works great!):
******into form actions Java Script********
if (app.viewerVersion < 11) {
import_pre_11();
} else {
import_11();
}
******into document java script; Import_File (create/add new)******
// Initialize attachment number
attachment_num = 1;
// Initial location of file attachment icon
// The x value is incremented below
var oFAP = {x_init: -72, x: -72, y: -72}; // Below lower-left corner of the page
function import_pre_11() {
if (app.viewerType === "Reader") {
app.alert({
cMsg: "You must user Reader version 11 or later to attach files to this form.",
cTitle: "Attach File Error",
nIcon: 3,
nType: 0 });
return; }
// Prompt user to import a file
//app.alert({
//cMsg: "Click the OK/Open button after selecting the //file from your system that you want to attach.",
//cTitle: "Attach File",
//nIcon: 3,
//nType: 0
//});
try {
var rc = this.importDataObject("Attachment" + attachment_num);
if (rc) {
attachment_num += 1;
app.alert({
cMsg: "Attachment successful.\r\rUse the Attachments panel (on the left) to access the attached file(s).",
cTitle: "Attachment Successful",
nIcon: 3,
nType: 0 });
} else {
app.alert({
cMsg: "Attachment cancelled.",
cTitle: "Attachment Cancelled",
nIcon: 3,
nType: 0 });
}
} catch (e) {
app.alert({
cMsg: "Could not attach file.",
cTitle: "Could not attach file",
nIcon: 3,
nType: 0 });
}
}
