Monday, June 23, 2008

Add Tagging To Your Mail (Or Any Other Application) Without Design Changes!

If you'd like to find out how to add simple tagging capabilities to your Lotus Notes applications without making any design changes, then keep reading...

As a way to increase my productivity in processing e-mail, I stopped using folders for filing a few years ago. This is especially easy in Lotus Notes 8, since the search capabilities are much nicer and have been enhanced in such a way as to make me very happy I made this choice. Basically, when I process e-mail, I determine if the message is actionable and if so, I decide what to do with it and then remove it from the inbox. I don't file it in a folder...I just choose the "Remove from Folder" action. Clean, simple and gets the job done. I did find, however, that quite often the text that is included in the e-mail does not contain the actual meta data that I would later want to search on. Thus, I found myself editing messages and adding the key phrases related to the e-mail before I removed them. Of course, what I was doing is known by most people as tagging and I realized that a simple mechanism for tagging is exactly what I wanted.

In my last job, I had a highly modified mail file that I used for my GTD system as well as for other productivity enhancements (and as a playground for off the wall ideas, I must confess). When I came into the tech sales role at IBM, I decided early on that I should use the generic mail template, since I would be doing so many demos for customers. As a result, my initial tagging mechanism had to morph to something that required no design changes. I thought that whatever I came up with should be useful for others, but didn't want to spend the time building a complete solution in another NSF. So, I decided to see if I could utilize Formula language in a custom toolbar button. The result, while not elegant by any means, is quite efficient and works well for me, so I thought I'd throw it out here to share.

Here's the scenario. I select the document in question and click my "Tag It" toolbar button. To allow for choices from tags I've already used (for continuity and best search results), I pull up a dialog box of previous tags and also allow new tags to be added. Once I have the necessary tags for the document selected, they are saved into a new field on the document. That's pretty much all there is to it from a user point of view. Here are a couple of screen shots to illustrate:




In order to make this work on a per application basis, I save the list of tags used in a profile document. The first line of the code pulls up the list of previously used tags, while the second line retrieves any of the tags that might already be assigned to the selected document. The next few lines provide for a multi-list dialog, along with logic that checks for the selection of "-add new-". If the "-add new-" option is chosen, the user is prompted to enter new tags (separated by commas) and the updated list of selected tags and any newly entered tags are written to the "txt_CustomTags" field. Finally, the last line makes sure any new tag values are written back to the profile document for use next time.

REM {Get tags stored in database};
Tags := @GetProfileField("TagsProfile";"txt_CurrentTags";@UserName);


REM
{Get any tags from the selected document};
DocTags := txt_CustomTags;

Selection := @Prompt([OkCancelListMult]; "Select Tag(s)"; "Please select the tag(s) to apply to this document"; DocTags; @Trim("-add new-" : @Unique(Tags : DocTags)));

@If(Selection = 1;
  @Return("");
@IsMember("-add new-"; Selection);
  @Set("NewTag"; @Prompt([OkCancelEdit]; "Enter New Tag"; "Please enter the new tag(s) you would like to apply to this document. Separate tags with a comma"; ""));
  "");

UpdatedList := @Trim(@Unique(@Replace(Selection; "-add new-"; "") : @Explode(NewTag,"," )));


FIELD
txt_CustomTags := UpdatedList;

@SetProfileField("TagsProfile"; "txt_CurrentTags"; @Unique(UpdatedList : Tags); @UserName)


For completeness, I also include a toolbar button to wipe out any tags on the document (FIELD txt_CurrentTags := @Unavailable).

So, as you can see, while adding a true tagging mechanism would be ideal, this solution makes it very easy for me to tag documents in my mail file and then use the standard Notes search mechanism to retrieve them more easily. While your mileage may certainly vary, it's a great way to give users the tagging ability without changing any database designs.

18 comments:

YeloCAB said...

Brilliant! I am going to add this button to my toolbar.

John said...

this is a great solution, but what good is tagging if it is not displayed to the user? Where is the view and/or tag cloud? I am missing something ...

Vitor Pereira said...

@John, Chris mentioned searching. You can't see the tags but you can search.

YeloCAB said...

If you were to limit your tags (boss, performance, personal, kudos, wife, great ideas, etc.) you could create an agent that would put them into folders and run that on a regular basis. That way, things could immediately be tagged, but filed later via the agent.

I'm using this for e-mail, where we can't edit the design of the e-mail Db.

(Perhaps I will add some code to change the _viewIcon so that I know what is tagged or not.)

One thing, the @Explode(NewTag) should be @Explode(NewTag;",") in order to split the keywords by comma (rather than spaces, as I just discovered).

Chris Blatnick said...

@John...You're right, this solution doesn't provide for visual representations of the tags but that's the price to pay the flexibility of not modifying the design. If you can do it, adding a tag cloud or similar is the ideal solution. In this case, you have to use standard search.

Vitor Pereira said...

One more thing.
You can combine this with a subset of Chad Schelfhout's "Edit Document Fields" code and update multiple docs.

Check here for Chad's code.

Chris Blatnick said...

@Yelocab...thanks for the catch on the @Explode. I've fixed this in the post. If you do make any additions, please feel free to share here. Thanks! :-)

Chris Blatnick said...

@Vitor...That sounds good. I'll have to check that out. Might be a really cool update Thanks!

Elf said...

@Chris: How is it possible to do this, without changing the design? I mean, you add a new button, a new form and new code.

Maybe this is a functionality that doesn't exist in Notes 6.5, which is what my company is running.

Vitor Pereira said...

@Elf... it's a toolbar button, no need to change the design and it work's with any application.

YeloCAB said...

@Chris: I thought more about changing the view icon (in by inbox)--but am a little hesitant. I will have to ponder that a little more after I have a chance to use tagging a while. I also considered adding a character before or after the subject to indicate the doc has been tagged (probably adding a character at the end of the subject would be best for sorting by subject, later on).

Nigel Choh said...

Just a little typo, Change the comma to a semi-colon for the @Explode.

Great idea

Phil said...

In case anyone is interested, I've taken some of the comments/ideas in this post and have extended this function slightly. I've blogged about it here, and Vitor mentions that he also did some work with it and perhaps that putting things from both our solutions together, we may come out with something more useful and reliable than what I've come out with so far.

KeithC said...

OK, maybe I'm dumb, but how do you search for the tag value?

Chris Blatnick said...

@KeithC - So right now, I just use the full-text search capabilities to look for tags. I originally wanted to make something I could use in any database, not just mail, so I didn't build a custom function to search tags. This would be really easy to do, however, and would greatly improve the functionality.

KeithC said...

Hi Chris

thanks for the response, of course I knew about full-text search and I was perhaps doing a bit of wishful thinking ;-). Don't you get a lot of false positives using full-text search? For example, if I wanted to tag things like eProductivity, GTD, etc as "Organization", I would see every mail with that word. So either I use perhaps non-intuitive tags (somewhat defeating the object) or get lots of hits that aren't real.

Maybe if I made each tag something like ":T: real subject" it would help me - but then I have to remember to get that prefix every time.

Certainly an idea with a lot of potential. I am thinking of giving up on folders for a different reason (totally corrupted folder structure in my archive means that things in folders in the mail database don't get filed correctly in the archive).

Vitor Pereira said...

@KeithC - If the db is full text indexed and you use this sintax:
[tags]=GTD you will only get the documents where the "tags" field contains GTD

KeithC said...

@Vitor

thanks! Perhaps because I work for IBM and joined through an acquisition I didn't get any real training on anything other than the basics - mostly "look isn't Notes wonderful, it can do this" "yes, like every other email program I have used for the last fifteen years"