Tip

Display Attachments Where You Want

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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.