Wednesday 26 March 2008

I stand corrected, form formula and Dojo Dialog does work !

It seems I made a small mistake with big consequences. And the good news is that the form formula does work with dojo dialog.
While I was preparing the functionality mentioned in yesterdays post for go live, I discovered it did not work after cleaning up (deleting) all the trial code.

The mistake was, I called the wrong view in the "/viewname/docid?OpenDocument" for the dojo dialog. This mistake was caused by the application having 2 views with an almost similar name and the view I called did not have a form formula, which is why it rendered the Notes format of the form in the dojo dialog instead of the webformat.

Fortunately this mistake was quick to fix, by pointing the url to use the correct view.
So when reading yesterdays post, please ignore the text about the form formula not working.

Tuesday 25 March 2008

Form formula with Dojo Dialog

It has been a while since Lotusphere, but today I put some functionality live that I had created after being stunned at Lotusphere by the session (BP212) that displayed some of the features in Dojo together with Notes/Domino. In fact Viktor Krantz had made a real effort in creating seperate javascript objects for Domino to show in his demos at BP212.

Putting this code live, reminded me that I wanted to write something about Dojo and the fact that for some reason the form formula is not working when opening a document using dojo dialog.

So returning from Lotusphere I started looking into Dojo and implemented the Dojo grid and Dojo dialog. As I wanted to have some handson with dojo, I did not re-use the Domino objects from BP212.
I made a grid working using the JSON setup Scott Good had shown in his ajax/json session (JMP205). This was actually the most work and required the most lines of javascript (mainly building the search url and the grid layout).

I then created a simple html form to open in a dojo dialog that will be triggered by clicking on a row on the dojo grid. All works fine, except the form specified in the form formula of the view that is used to retrieve the document does not seem to work. It uses the Notes version of the form instead of the specified web format.
I double checked twice and using the same "viewname/docid?OpenDocument" directly in the browser does open the specified web format as specified in the form formula.
Searching the web (LDD a.o.) did not give any clues into this problem having occurred before, nor did posting this problem on the LDD forum result in any answers.
So in the end I solved this problem by using computed subforms, one for the Notes client and one for the web
.

Has anyone else come accross this problem? Forget this, it does work, see the post on 26-03-2008.

For samples of code look at the Lotusphere session:
JMP205 AJAX and JSON for IBM Lotus Domino Applications (Scott Good)
BP212 The Great Code Giveaway: "Beyond Cool" (Rob Novak & Viktor Krantz)

Sunday 9 March 2008

Moving values up and down in multiple multivalue fields

A while ago I received a request to be able to maintain a table of values. In Notes that means creating several multivalue fields that are displayed in a table.
I had done this before using the tablewalker solution by Michael Rohrbach and it still works fine after all these years.
However the current user was not really satisfied with the sorting option in the Tablewalker solution and wanted to be able to visually move rows up and down. This is basically moving values up and down in multivalue fields. So I started thinking about how to do this while the user is viewing the table on the form using @functions.
Based on an application I found on OpenNTF by Tomas Ekström, TEd, Table Editor I build a fairly simple solution for this using @functions.

This is the solution:
To start I created a computed multivalue field in which the fields to sort are stored, I called this field "MoveFields".

On the form there are a couple of (hidden) multivalue fields to hold the user data and computed for display fields to display the values of the hidden fields neatly in the table (cut-off if need be for each seperate value to fit on one line).
To move the values up and down in the array I added an extra field in which the user can enter the row to move "CurrPos".
Finally two arrows (up and down) are added with action hotspots, in which the sorting is done. The code should be self-explanatory.

Screenshot of the (part of) the table and buttons:











Code for the up hotspot:

REM {CODE FOR MOVING UP };
Fields := @GetField("MoveFields");

NoOfFields := @Elements(Fields);
NoOfElements := @Elements(@GetField(Fields[1]));

@If(CurrPos < 1 | CurrPos > NoOfElements;
@Return(@Prompt([Ok];"move up"; "Number must be within range of available rows"));
""
);
@If(CurrPos = 1;
@Return(@Prompt([Ok];"move up"; "Cannot move the first row further up !"));
""
);
REM { ----------------------------------------------------------------------------------------------------------
move the current row one position UP
1st subset gets the elements above the current element and the element to switch (only when current position is below second row)
2nd subset gets the current element
3rd subset gets the element above the current element
4th subset subset gets the elements below the current element (only when current position is above the last position)
-------------------------------------------------------------------------------------------------------------------- };
@For(n:=1; n <= NoOfFields; n:=n+1;
@SetField(Fields[n];
@If(CurrPos <= 2; null; @Subset(@GetField(Fields[n]); CurrPos-2)) :
@Subset(@Subset(@GetField(Fields[n]); CurrPos);-1) :
@Subset(@Subset(@GetField(Fields[n]); CurrPos-1); -1) :
@If(CurrPos = NoOfElements; null; @Subset(@GetField(Fields[n]); CurrPos-NoOfElements))
)
);
REM { set currunt position to new rownumber };
@SetField("CurrPos"; CurrPos -1);
@Command([ViewRefreshFields])


Code for the down hotspot

REM {CODE FOR MOVING DOWN };
Fields := @GetField("MoveFields");

NoOfFields := @Elements(Fields);
NoOfElements := @Elements(@GetField(Fields[1]));

@If(CurrPos < 1 | CurrPos > NoOfElements;
@Return(@Prompt([Ok];"move down"; "Row number must be within range of available rows"));
""
);
@If(CurrPos = NoOfElements;
@Return(@Prompt([Ok];"move down"; "Cannot move the last row further down !"));
""
);
REM { ------------------------------------------------------------------------------------------
move the current row one position DOWN
1st subset gets the elements above the current element and the element to switch (only when current position is below first row)
2nd subset gets the element below the current element
3rd subset gets the current element
4th subset subset gets the elements below the elements to switch (current element +1) (only when current position is at least 2 rows the last row)
----------------------------------------------------------------------------------------------------- };
@For(n:=1; n <= NoOfFields; n:=n+1;
@SetField(Fields[n];
@If(CurrPos = 1; null; @Subset(@GetField(Fields[n]); CurrPos-1)) :
@Subset(@Subset(@GetField(Fields[n]); CurrPos+1);-1) :
@Subset(@Subset(@GetField(Fields[n]); CurrPos); -1) :
@If(CurrPos = NoOfElements-1; null; @Subset(@GetField(Fields[n]); CurrPos+1-NoOfElements))
)
);
REM { set the current position to the new row };
@SetField("CurrPos"; CurrPos +1);
@Command([ViewRefreshFields])

Thursday 6 March 2008

Another blog about Lotus Notes / Domino development

Indeed yet another weblog about Lotus Notes / Domino development. After roaming other blogs for answers and solutions I thought it would be time I started sharing my coding experiences on a world wide weblog.
Now, being a Notes / Domino developer it would seem appropriate to use a domino database for blogging. But as I found, hosting a domino site is rather expensive for a private person, I chose to start blogging through Google.
I do not have the idea that I can do a better job than some of the bloggers out there that have been around for several years now. But I consider this as much a personal diary as an attempt to share my experiences with a broader audience.

For now I have picked a readily available template, but I hope to create a more personal layout in the near future.