I am currently working on a huge application which exists for many years now, and has a long history with different developers and just a few manuals and/or documentations. But as often it is a critical business application which is in use across different countries 24/7. The more danger, the
more less honor: Every fault is just a further nail in the coffin of the developer…
Today I had to develop an extension for this application, and this has driven me crazy, because it was a pain to identify to problem: After creating a document from a XPage the workflow stopped. When filling out the form in in the NotesClient the problem did not occur. But using the same form in a XPage (with computeWithForm) did not work.
After investigating I found out that the problem was caused by a required field which was not created. It was just not there, nothing, nada.
In the form it was defined as a computed field…
… but even with a simple XPage …
<?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xp:this.data> <xp:dominoDocument var="document1" formName="Doc" computeWithForm="onsave"> </xp:dominoDocument> </xp:this.data> <xp:button value="Save" id="buttonSubmit"> <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true" /> </xp:button> <xp:br /> <xp:messages id="errMessages" /> </xp:view>
… the field was not created:
[I have tried the computeWithForm parameter with every available option.]
Searching for a quick workaround I tried to use an oldschool LS agent, but even then the mystery was not solved. Instead, it grew:
%REM Agent ComputeWithForm Created Jul 17, 2013 by Sven Hasselbach/Hasselba/CH %END REM Option Public Option Declare Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim doc As NotesDocument Set db = session.Currentdatabase Set doc = New NotesDocument( db ) doc.Form = "Doc" doc.Computewithform True, true doc.Save true, false End Sub
This was the resulting error message:
When opening the form in the NotesClient and saving the document, everything works as expected:
What’s going on here? It was really interesting to find the reason. In the last years I always thought that computed fields have always values defined in the form. But this is not a requirement for author fields:
Adding a simple @UserName to the field, and the issue was solved.