#oldschool @formula to check for attachments

I have started at a new company and they didn’t have an XIC (XPages Information Center) so my XPages Knowledge db needed to be installed (a regular Notes db for quickly copying & pasting rich text, snippets, storing sample applications, multiple media files).

The database is a couple of years old so it needed some updates. One was to hide a “files section” from printing in case there are no files attached. I noticed embedded images start with an “ST” naming in the @attachments array (correct me if I am wrong).

Finally I came up with the following rule for a computed sub form:

REM{“check if files contains a point. embedded images do not contain them”};
@For(n := 1;n <= @Elements(files); n := n+1;

2 thoughts on “#oldschool @formula to check for attachments

  1. Ben Langhinrichs 2014-April-7 / 7:59 pm

    It is a little more complicated than that. Every OLE object will have an attachment called EXTnnnnnn, and then a series of attachments called STGnnnnn (not the same number), but older versions of Notes (maybe newer ones as well) may not have an extension if there is a duplicate file. If I attach a file called invoice.pdf, and then another called invoice.pdf, the second will usually be ATnnnnn. If I delete the original attachment, I am left with only ATnnnnn, which would not show the section according to your formula. That may seem unlikely, but if I have a document keep replacing the file to update with the latest, it can happen quite easily.

    It is also possible to have MIME parts as attachments, but those would have extensions.

  2. Dan Sickles 2014-April-8 / 5:39 am

    This eliminates several opportunities for error in the for loop index management and counter increment::

    counter := @Sum(@Transform(@AttachmentNames; “fileName”; @if(@Contains(fileName; “.”); 1 ; 0 )))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s