Open Attachment in New Window on Web

After a lot of tweeking, I got the following url in a view to open an attachment.

http://server/file.nsf/(View)/docuniqueid/$File/ChangeForm.pdf?openElement

It works fine. However, I need the attachment to in a new window. How do I get that to happen from a view?

Subject: Open Attachment in New Window on Web

try this…

"<a href=’

http://server/file.nsf/(View)/docuniqueid/$File/ChangeForm.pdf?openElement

target=‘_blank’>“+ViewColumn+”"

Don’t forget brackets ] on both sides to indicate passthrough html.

Subject: Open Attachment in New Window on Web

Add this code to a column in a view, and treat the view as HTML.

REM { This code makes HTML links for all the attachments };
REM { The following FIELD items are being created here and used localy,
they do not exist in any form };
FIELD DB_Pth := “/FOLDERNAME/”;
FIELD DB_Name := “YOURDB.nsf”;
FIELD Unknown := “/0/”; REM {
just a guess, but this may be the session ID };
FIELD Doc_ID := @Text(@DocumentUniqueID);
FIELD Attachments_dir := “/$FILE/”;
FIELD Attachment_names_as_list := @Implode(@AttachmentNames;“;”);
FIELD NumAt := @Attachments; REM { The number of
attachments to this document };
FIELD All_Links := “”;

REM { for all the attachments, add a link to that attachment to the All_Links
field};
@For( index := 1;
index <= NumAt;
index := index + 1;
@Do( Attachment_name := @Word(Attachment_names_as_list;“;”;index);
Attachment_link := DB_Pth + DB_Name + Unknown + Doc_ID +
Attachments_dir + Attachment_name;
FIELD HREF := " A TARGET="_blank" HREF="" +
attachment_link + " ">“+ Attachment_name +”
]";
All_Links := All_Links + HREF
));
REM { output the value of all links };
@Text(All_Links)

Subject: Open Attachment in New Window on Web

Hello,

Here is a piece of code I found years ago in one of the forums. You should be
able to copy and paste this into a column of your view.
De-select ‘show values in this column as links’, last tab in the column
properties. Should do this for all columns, unless you want one of the columns
to open the actual document.

DBName := @ReplaceSubstring(@ReplaceSubstring(@Subset(@DbName;
-1);“”;“+”);“\”;“/”);
REM {only change here, in my document i either show the attachment description
or the attachment name};
i := @If( tx_attdescription = “”; @AttachmentNames; tx_attdescription );
open:= “?OpenElement”;

REM {Declare view name};
view:=@ReplaceSubstring(@ReplaceSubstring(@Subset(@ViewTitle;1);"
“;”+“);”\“;”/");

REM {Declare document ID};
docid:=@Text(@DocumentUniqueID);

REM {If there is space in attachment name, replace with +};
x:=@AttachmentNames ;
y:=@Left(x;“.”);
z:=@Right(x;“.”);
att:=@Explode(y;" ");

@If(@Elements(att)>1;@Do(@SetField(“attname”;@Implode( att ; “+” ) + “.” +
z));@SetField(“attname”;@AttachmentNames));

REM {Build URL link to attachment};

url:=“!–
→ <a href=/”+dbname+“/”+view+“/”+docid+“/$FILE/”+attname+"
TARGET="" + “New">+attname+” + i

  • “<img src="/icons/ecblank.gif">]”;

REM {If attachments exist then show, otherwise, don’t};

@If(!@Attachments;“”;url)

Subject: RE: Open Attachment in New Window on Web

Great code James- I know I will have trouble finding it when I want it. :wink: thanks.

Subject: Thanks all - Great work