Deleting web attachments hidden with $V2AttachmentOptions

My users do not like Domino’s default display of attachments at the bottom of web documents under a horizontal rule.

I can hide them using $V2AttachmentOptions, and display the attachment’s names using the following computed text:

@If (@Attachments = 0; @Return(“”); “”);

ThisDb := @ReplaceSubstring(@Subset(@DbName; -1); “\”:" “; “/”:”+");

res := @Implode(“<a href="/” + ThisDb + “/($vAllByUnid)/” +

@Text(@DocumentUniqueID) + “/$file/” + @AttachmentNames + “">” +

“<span style="font-family:arial;font-size:8pt;color:blue;text-decoration:underline;">” +

@AttachmentNames + “”;


”);

“[” + res + “]”

This works great, but the users also want the ability to delete attachments. Anyone got some advice on how to do that?

Thanks everyone,

-Jeff

Subject: Deleting web attachments hidden with $V2AttachmentOptions

I did something similar with a single checkbox field. The options for the checkbox were @attachmentnames. I also put the following code in onChange event to prompt the user.

if (this.checked) {

if (!confirm("Delete " + this.value + "?")) {

	this.checked = false

}	//if (!confirm("Delete " + this.value + "?")) {

} //if (this.checked) {

WQS agent will loop through this field and remove attachments by calling the following function for each element in the field

Function RemoveAttachment(doc As NotesDocument,Attachment As String) As Boolean

Dim obj As NotesEmbeddedObject

Dim returnVal As Boolean



Set obj = doc.GetAttachment(Attachment)



returnVal = False

If Not obj Is Nothing Then

	obj.remove

	If doc.save(False,False) Then

		returnVal = True

	End If		'If doc.save(False,False) Then

End If		'If Not obj Is Nothing Then



RemoveAttachment = returnVal

End Function

Subject: Deleting web attachments hidden with $V2AttachmentOptions

Best method is to create an input checkbox named %%Detach. See Steve Cochrane’s note: http://tinyurl.com/7o2dg

Here’s my final solution:

@If (@Attachments = 0; @Return(“”); “”);

ThisDb := @WebDbName;

att := @AttachmentNames;

@Implode(“<input type="checkbox" name="%%Detach" value="”+att+“">”);

checkbox := @If(@IsDocBeingEdited; "<input type="checkbox" name="%%Detach"

value="“+att+”"> "; “”);

res := @Implode(checkbox + “<a href="/” + ThisDb + “/($vAllByUnid)/” +

@Text(@DocumentUniqueID) + “/$file/” + @AttachmentNames + ""

target=attachmentwindow>" +

"<span

style="font-family:arial;font-size:8pt;color:blue;text-decoration:underline;">

" +

@AttachmentNames + “
” + @NewLine;

“”);

“” + res + “”

Subject: Deleting web attachments hidden with $V2AttachmentOptions

I’d suggest deleting the attachments via a WebQuerySave agent that fires when the document is submitted.

The list of attachments to be deleted can be written to a hidden Input on the page via Javascript. e.g. each attachment name would have a second link <a href="Javascript:deleteAttachment(‘MyAttachment.txt’)>delete that calls a common javascript routine that simply writes the passed name of the attachment to the field.

The WQS agent picks up the list of attachments to be deleted from the field, and removes them before clearing the field down.

HTH - Rufus.