Showing posts with label show'n-tell-thursday. Show all posts
Showing posts with label show'n-tell-thursday. Show all posts

Friday, June 8, 2007

Formula-console in Notes

I really like this one, although it's a really simple one (maybe that's one of the reasons I like it so much).

Call it my Mac Gyver tip of the week (in a french blog, the tip to check the online status of the server with ecblank.gif/onerror-event was called something like that).

I've sometimes got really fed up developing formulas for computed fields, view columns, transforming dblookups, you name it. Just the other day, I thought this one up.

Make a form with an editable input field. Make a hidden SaveOptions-field (computed for display, default value="0").

The editable field is where you type formula-code. The nice thing about notes-fields is that they are multi-line, so you can write quite complicated formulas.

Below the text, write Result: or something like that. Then add a computed text with this formula:

test:=@Eval(inpEval);
@If(@IsError(test);@Text(test);test);


F9 (refresh) to execute the formula.. TaDa! You have your own formula-console.. :)

I have added a toolbar-button in the designer and client, so that I have instant access to the "console".
@Command([Compose];"server": "databaseWithTheForm";"nameOfFormulaConsoleForm")

A little update: If you use a button to @Eval the text-field, you can also execute some UI-formulas, that you can't execute from a computed text.

Using html and computed for display-fields for temporary values


Date: <input name="dateChanged" type="text" /><br />
Changed by: <input name="changedBy" type="text"><br />
Description of change:<br />
<textarea name="description" rows="5" cols="40"></textarea>


Hidden fields on the form:

<!--
Computed for display - default value/name=name of html-field
-->



<!-- Computed -->



Example code for the historyChange:

change:=dateChanged+", "+changedBy+": "+description;
@If(change="";
historyChange;
historyChange:change
);


This code concatenates the field-values to a string, and adds the string as a text-list item in the historyChange-field.

In the form that I use this method, I have a date-picker on the date-field ( and the field is readonly ), and the value is a computed text, @Text(@Today).

Other uses is for instance a checkbox that controls what happens to a document when it's saved, but has no other real purpose. The values in this example can be accessed by computed fields, webquerysave agents, etc.

Remember to put computed fields below the computed for display fields.

Saturday, May 5, 2007

Run agents onserver with a toolbar button



This is mostly borrowed code/design elements from a colleague of mine, Kjetil Grødem (sorry Kjetil).

The functionality I've added is using environment variables to remember which agent was last run, to save time when developing new agents to run on server. I've also made the formula needed to have the "runonserver" accessible from the toolbar in Lotus Notes, both of which were no major tasks.. :)

Demo-db with the subform and agent needed:
>> Download

Formula for toolbar-button:
====
@Command( [FileOpenDatabase]; "server": "dbpath");
@Command([ToolsRunMacro];"aos");
@PostedCommand([CloseWindow])
====
server=server
dbpath=path to database that the aos-agent/subform lies

Screenshot: