API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Another Use For Computed Text
When you want to have some kind of indicator showing required fields (an image or something), you have a choice to make. You can either show that image when the user is in read mode (which may prompt the response - how can it be required if I can't change it) or duplicate the line and have one line hidden in read mode (the one with the image) and one line hidden in edit mode (the one without the image). In R6, you can now do everything on one line.

What you want to do is use computed text combined with pass-through HTML. The Notes 6 client now recognizes pass-through HTML, so the client will render your HTML. The computed text shows the image in edit mode and does nothing in read mode. For example:

@If(@IsDocBeingEdited; "<IMG SRC=\"/icons/vwicn159.gif\">"; "")

The above code will put the "star" view icon () on the form if the document is being edited. This could be used to indicate required fields, and will only appear if the document is being edited. So, no more hide-when formulas if you use an image to indicate required fields.

If your image is a custom image (instead of something that every Notes client is going to have) you can still use this technique. Create an image resource with your image in it. Let's say it's called "star.gif" in your list of image resources. You would change your computed text to be:

@If(@IsDocBeingEdited; "<IMG SRC=\"/" + @WebDbName + "/star.gif\">"; "")

The @WebDbName is a new 6 formula that gives an HTML path to the current database. So, no matter what directory this database is in, the Notes client should find the image resource.

Special Note: Neither one of these techniques work for a local version of the database. They only work on the server. That's because of the HTML paths being generated - they are completely different if you're going after a local image. You have to know the full path to your icons subdirectory to show an image. For example, if the path is c:\notes\data\domino\icons, then your HTML needs to be <IMG SRC="file://c:/notes/data/domino/icons/vwicn159.gif"> to show the star icon. I haven't been able to get them to work (even hard-coded) for image resouces. If anyone has been able to show images on a local Notes database using pass-through HTML (with something that isn't hard-coded), please post a response and I can update this tip.

If the database is going to be used locally, then you can prevent the red box from appearing (no image found) by check to see if the user is on a local replica. So your computed text now becomes:

@If(@DbName[1] = ""; ""; @IsDocBeingEdited; "<IMG SRC=\"/icons/vwicn159.gif\">"; "")

So, if the user is on a local replica, nothing will appear. You could enhance this to check to see if the document is being edited on a local replica and put in some hard-coded text like "required" in a smaller font or something. But you get the idea.