PreviousNext…

Show ’n’ tell IV: looking up rich text

Show-n-tell Thursday logoRich text and @DbLookup. Incompatible with each other? Not so.

This tip is ancient: Notes old-timers will know it. However, I’m often surprised at how few people have come across it, so seeing as I used it again very recently (the forthcoming new version of DominoWiki of course!), I figured I would present it here for your delectation and delight.

Accepted wisdom has it that @DbLookup and @DbColumn can’t make use of rich text fields. But they can. All you need do is write some formula in the normal way, ensuring that the field in question is not referenced in the look-up view directly (i.e. in a column—but then why would you be doing that anyway? Ordinarily views can’t present non-summary data). Here’s an example. I have a configuration document that contains a rich text field. This field is called Header and has a custom mail header in it—embedded graphics and what-have-you. My application makes use of the Personal Stationery form to send out custom mails. This form also has a field in it called Header. So why not define some formula in its Default Value event to pull through that centrally-defined email header:

	lu := @DbLookup("Notes" : "Cache"; ""; "vwConfig"; "frmConfig"; "Header");
	@If(@IsError(lu) | lu=""; ""; lu)

Simple! Note the look-up view and key values used above, with the field being the piece we want. Obviously you will need to tailor this. Also, apologies for the R5-style error-trapping around the look-up: old habits die hard!

A final word of caution. Look-up formulae have a limit (around 64Kb). If you decide to feed through a lot of rich text—very easily done, especially if you’re dealing with imported graphics—expect the solution to break as you hit that limit.

Comments

  1. Nice one Ben. The error trapping is correct as of ND7 again, @IfError has been deprecated "because it never worked the way it was intended to"!

    So no need to change your habits there.Matt White#
  2. Interesting! I was actually referring to my not using the [FAILSILENT] keyword in the look-up function itself, but good to know about @IfError. I really need to play with 7.Ben Poole#
  3. I've been around a while and I didn't think of that. Thanks, Ben.Mike Kretzler#

Comments on this post are now closed.

About

I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

";