Create computed action hotspots on the flie using @Formula

We know the power of action and link hotspots. It would be great if we could create them computed, f.e. to give it a computed description or to create a number of hotspots that can vary. I’m sure you know some applications for this yourself (just nostalgically think of those times you bumped your head against the wall in rage ;-)).

It turns out not to be that difficult, but there are some gotchas and restrictions. But don’t be afraid, I’ll take you by the hand and show you where the mines are…

How does it look?

It could look like this:

Computed action hotspots using @Formula

The basics

The months in this example are generated in a computed value with @Formula. The computed value is marked as passthru html.

I used a multivalue field CostMonth and with a @For-loop I wrapped a link around every value.

@For(i:=1;i<=@Elements(CostMonth);i:=i+1;

   @If(i=1;LB:=“”;LB:=“<br>”);

   link1:=“javascript:clickRow(“+@Text(i)+“)”;

   result:=result+LB+“<a href=\”“+link1+”\“>”+CostMonth[i]+“</a>”

);

The link is actually a link to a JavaScript function in the JSHeader that presses a button for us. Something like:

function clickRow(row) { document.forms[0].myButton.click(); }

Don’t forget to give the name/id “myButton” to that button. The button itselfs can hold formula, lotusscript or whatever your heart desires.

I used linebreaks <br> for new lines, I tested with <br/> as well, this didn’t work. But, we’re not there yet, this is the result so far:

Simple action hotspots

Hey, that’s not the font I want! That’s not the color I like!

Changing font, color and interlines

I tried css to change the look of the links, but I had little to no success. Alternative: surrounding the link tags with <font> tags. This can alter the font color and font face.

Oh, but there was trouble, there were headaches, there was darkness! If I put the font tag outside of the link tag, the color didn’t change (because it took the default link color over. If I put it inside of the link tag, the interline is huge (and that makes sense, because the font is still wrong outside of the link tag).

So, what I did was changing the size and face outside of the link tag, and changing the color in the link tag. The code becomes:

@For(i:=1;i<=@Elements(CostMonth);i:=i+1;

   @If(i=1;LB:=“”;LB:=“<br/>”);

   link1:=“javascript:clickRow(“+@Text(i)+“)”;

   result:=result+LB+“<font size=\”0\” face=\”Tahoma\“><b><a href=\”“+link1+”\“><font color=\”#0082BF\“>”+CostMonth[i]+“</font></a></b></font>”

);

Taking it further

Buttons can be generated with passthru as well, here’s an example:

@For(i:=1;i<=@Elements(CostMonth);i:=i+1;

   @If(i=1;LB:=“”;LB:=“<br>”);

   link1:=“javascript:clickRow(“+@Text(i)+“)”;

   result:=result+LB+“<font size=\”0\” face=\”Tahoma\“><input type=button value=\”“+CostMonth[i]+”\” onClick=\”“+link1+”\“/></font>”

);

Images can be used as well, but this is a bit more cumbersome, because the images will need the http task to be shown, so I don’t really recommend this.

7 Comments

  1. This works nicely with notes://server/replica/0/docid Links to. I used this to do some “See also: . Unfortunatelly haveing computed html text seems to require, that there is a linebreak in front of it, so you can’t put such a link inside your normal text unles you put teh rest of the paragraph into the same passthru computed text.

    Reply
  2. Nice article. Thanks. :) Eugene

    Reply
  3. This is such a cool technique: finaly translations for buttons! Now only two places remain: view headers and the labels for “action with subaction” (seems a bug, actions itself are using the right computed label)

    Reply
  4. Nice post. Thank you for the info. Keep it up.

    Reply
  5. Martin,
    Very useful for an intranet project I’m doing right now.
    It also works with and .
    Strange though, that you need to use a computed text. It does not work with a computed (for display) field.

    Reply
  6. Beware of @For loops and too many elements, though. At some point you WILL run into issues with the maximum memory available to a formula. Usually, you can accomplish the same thing using plain old list operations.

    The downside is, that this is much less readable than a loop and doesn’t come naturally for programmers not used to the power of @Formula list operations. But on the other hand, it can really handle much more entries and will perform noticeably better.

    Reply

Leave a Reply to Jan Schulz Cancel reply

Your email address will not be published. Required fields are marked *

49 − 43 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>