Don't you hate when you have attachments on the Web and you have to scroll down to the bottom of the rich text field to get them. With this solution, you can put your attachments in a different field on the form, add an icon to the left of it and make it a live link so that you can either click on the attachment icon at the bottom or the link that is displayed. You can even do more tests on the attachment type to display different icons. Enjoy.
Put the following code into a "computed for display" text field.
sView := "WebAllMessages";
@If(@Attachments = 0; @Return(""); "");
sDoc := @Text(@DocumentUniqueID);
sBaseURL := "/" + @ReplaceSubstring(@Subset(@DbName; -1); "\"; "/") + "/" + sView + "/" + sDoc +
"/$FILE/";
sImg := "[<img border="0" height="17" width="19" src="/icons/afolder.gif" align=bottom
alt="">]";
lsAttFiles1 := @ReplaceSubstring(@AttachmentNames; "%"; "%25");
lsFrom := " " : ";" : "/" : "?" : ":" : "@" : "=" : "&" : "<" : ">" : """ :
"#" : "{" : "}" : "|" : "\" : "^" : "~" : "[" : "]" : "`";
lsTo := "%20" : "%3B" : "%2F" : "%3F" : "%3A" : "%40" : "%3D" : "%26" : "%3C" : "%3E" : "%22" :
"%23" : "%7B" : "%7D" : "%7C" : "%5C" : "%5E" : "%7E" : "%5B" : "%5D" : "%60";
lsAttFiles := @ReplaceSubstring(lsAttFiles1; lsFrom; lsTo);
lsLens := (" (" + @Text(@Integer(@AttachmentLengths / 1024); ",")) + "k)";
lsAttNames := @AttachmentNames;
lsAttURLs := (sBaseURL + lsAttFiles) + "?OpenElement";
lsPrefix := ("[<a href="" + lsAttURLs) + "">]" + sImg + " ";
lsRefs := (lsPrefix + lsAttNames) + "[</a>]";
@Implode(lsRefs + lsLens; "[
]")
This was first published in November 2000