0
votes

when i save a Notes Document in a XPage with computeWithForm="onsave" there is nothing computed at the form.

I thought that the computeWithForm Option trigger the "QuerySave" Event in the form, but am i wrong ?

I know that i could use the querySaveDocument Event at the Xpage DataSource, but there is a lot of lotusscript logic :-)

form:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE form SYSTEM 'xmlschemas/domino_9_0_1.dtd'>
<form name='testform' xmlns='http://www.lotus.com/dxl' version='9.0' maintenanceversion='1.9'
 replicaid='C125827800263D1B' noquery='true' publicaccess='false' designerversion='8.5.3'
 recalc='true' renderpassthrough='true'>

<code event='querysave'><lotusscript
>Sub Querysave(Source As Notesuidocument, Continue As Variant)

    Dim doc As NotesDocument
    Set doc = Source.Document
    doc.test = "123"
    Call doc.Save( True, False )

End Sub</lotusscript></code>
<body><richtext>
<pardef id='1' leftmargin='1in' hide='notes web' tabs='L6.9375in'/>
<par def='1'/>
<pardef id='2'/>
<par def='2'><run><font name='Verdana' pitch='variable' truetype='true' familyid='20'/><field
 usenotesstyle='false' height='0.2500in' width='4.7243in' multiline='true'
 borderstyle='single' type='text' kind='editable' name='title'/></run></par>
<par def='2'><field type='text' kind='editable' name='test'/><compositedata
 type='98' prevtype='65418' nexttype='222' afterparcount='6' containertype='65418'
 aftercontainercount='1' afterbegincount='3'>
Yg4BAIQAAAAAAAAAAAA=
</compositedata></par></richtext></body>
<item name='$$ScriptName' summary='false' sign='true'><text>testform</text></item></form>

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="testform" computeWithForm="onsave"  />
    </xp:this.data>

<xp:inputText value="#{document1.titel}" id="titel1" />

<xp:br></xp:br>

<xp:button value="save" id="button1">
    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action>
            <xp:saveDocument var="document1" />
        </xp:this.action>
    </xp:eventHandler>
</xp:button>
</xp:view>
2

2 Answers

2
votes

computeWithForm only runs Input Translation and Input Validation formulas.

If you want to retain the LS logic, one option would be to move it to an agent (I believe you would need to change UIDocument classes to Document classes and re-code accordingly) and call the agent from XPages. It's not something I've done though, so I can't point you towards documentation.

0
votes

That's a misunderstanding! compute with form executes the @Formula that are in the associated form. It does not execute any form events or run LotusScript. If you want to use LotusScript, you need to pull it into an agent and explicitly call that agent (hint: Don't bother, translate your script to SSJS or Java instead).

That aside: you shouldn't call doc.save in a querySave event - there will be a save action anyway. You hit the disk twice (that's for Notes client apps, as mentioned that code doesn't run in XPages)