Genii Weblog

What is best way to call formula on web?

Mon 23 Feb 2004, 09:36 PM

by Ben Langhinrichs
I am working on a demo, and wondering what is the best way to call a formula or formula agent on the web.  There seem to be a few ways.  You can call a LotusScript agent and use it to call evaluate.  You can put the formula in a computed text and display the computed text.  You can create a formula button and compute and trigger the DoClick. You might even be able to call a formula agent directly with a URL.

But which is best?  Are any of them workable, or do they all have problems?  Any thoughts?

Copyright 2004 Genii Software Ltd.

What has been said:

119.1. Jerry Carter
(02/24/2004 05:58 AM)

Cool, this is a great topic.

Pretty much all of these approaches will require you to use the $$Return field or replace the content of the $$HTMLHeader field to return results to the same document.

If you want the code to execute 'on display', the computed text (or computed field if you want to make use of the information later) is the easiest and most direct. Unless there is a gain of some kind, maintenance or performance, to have the code in an agent, putting it in computed text is easiest to maintain and work with IMHO as it's a bit more like using something like PHP.

Action buttons work well to an extent on the web. Things like @command([FileSave]) work pretty reliably (but require the afore mentioned $$Return field of you want to truely mimic a Save event) though for complex forumulas I think they stretch the technologly a bit.

Another tricky way to call different segments of formula language to execute as needed is to use the Script tag src trick, where by you use javascript on your main form to switch out the src of the script tag. Requres giving the script tag an ID. Since you can name any element in a domino database whatever.js, as long as your formula language outputs properly formatted javascript functions or objects, you have a lot of lattitude and can get around page sumits.

Let me know what you settle on. This is a fun area to play around in.


119.2. Jerry Carter
(02/24/2004 08:08 AM)

I hadn't checked that out, but it's very nice - pretty smooth operation. I'm going to go broke at your restaraunt, though. ;-)

Yeah, computed text is very clean. A lot of the stuff I've been doing is simple @replacesubstrings against field contained base strings to reuse with variation the same html construct in several computed text areas across a single form.

As for some of the other methods, calling back to an agent always has extra baggage, but sometimes it's the most managable way for lots of complex code. For example, if you wanted Midas to get information from a relational database, you'd be better off suturing an evaluate into a lotuscript or java agent that handled the result set for you. Lots of possibilities.

119.3. Ben Langhinrichs
(02/24/2004 08:13 AM)

The trickiest part if cases where the actual document is modified, like a ReplaceMatching call I use (to replace keyword tags in rich with rich text blobs). These things are easy in the Notes client, but trickier on the web. I'm going to try the Script src trick you mentioned, although I must admit I'm not clear on where the actual formula language gets executed. Anyway, I'll let you know what I come up with.