0

I have a xapage that I created laid out the form etc. When I create a new document with it, it does not save the document. However if I edit an existing document that was created with the notes form it does save that. It is very odd. There are not any error messages, it just reloads the document again with empty fields. Below is my source code:

    <?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex"
    xmlns:xc="http://www.ibm.com/xsp/custom">

    <xp:this.data>
        <xp:dominoDocument var="document1" action="openDocument"
            formName="frmComm" computeWithForm="onsave">
        </xp:dominoDocument>
    </xp:this.data>

    <xp:this.dataContexts>
    <xp:dataContext var="parentDoc">
        <xp:this.value><![CDATA[#{javascript:
            try {
                if (document1.isResponse()) {
                    return database.getDocumentByUNID(document1.getDocument().getParentDocumentUNID());
                } else {
                    return "";
                }
            } catch(e) {
                return "";
        }}]]></xp:this.value>
    </xp:dataContext>
</xp:this.dataContexts>



    <xc:AppLayout>
        <xp:this.facets>
            <xp:panel xp:key="facetMiddle">

                <xp:panel>
                    <xc:ccFormActions></xc:ccFormActions>

                    <xp:panel>
                        <xp:panel><xe:formTable id="formTable1" formTitle="Communication">
        <xe:formColumn id="formColumn2">
            <xe:formRow id="formRow14" label="Policy Name:" rendered="#{javascript:document1.isEditable()}">
                <xp:inputText id="inputText1" value="#{document1.NameC}"
                    style="width:630.0px"
                    rendered="#{javascript:document1.isEditable()}" readonly="true">
                <xp:this.defaultValue><![CDATA[#{javascript:parentDoc.getItemValueString("Name");
}]]></xp:this.defaultValue></xp:inputText>
            </xe:formRow>
            <xe:formRow id="formRow11" label="Policy Name:" rendered="#{javascript:!document1.isEditable()}">
                <xp:text escape="true" id="NameV" value="#{document1.NameC}" rendered="#{javascript:!document1.isEditable()}">
                </xp:text>

            </xe:formRow>
            <xe:formRow id="formRow12" label="Policy Number:" rendered="#{javascript:document1.isEditable()}">
                <xp:inputText id="inputText4" value="#{document1.NbrC}" rendered="#{javascript:document1.isEditable()}" readonly="true">
                <xp:this.defaultValue><![CDATA[#{javascript:parentDoc.getItemValueString("Nbr");}]]></xp:this.defaultValue></xp:inputText>
            </xe:formRow>
            <xe:formRow id="formRow13" label="Policy Number:" rendered="#{javascript:!document1.isEditable()}">
                <xp:text escape="true" id="NbrV" value="#{document1.NbrC}" rendered="#{javascript:!document1.isEditable()}">
                </xp:text>

            </xe:formRow>
            <xe:formRow id="formRow10" label="Category:" rendered="#{javascript:document1.isEditable()}">
                <xp:inputText id="inputText5" style="width:169.0px" value="#{document1.CategoryC}" rendered="#{javascript:document1.isEditable()}" readonly="true">
                <xp:this.defaultValue><![CDATA[#{javascript:parentDoc.getItemValueString("Category");}]]></xp:this.defaultValue></xp:inputText>
            </xe:formRow>
            <xe:formRow id="formRow9" label="Category:" rendered="#{javascript:!document1.isEditable()}">
                <xp:text escape="true" id="CategoryV" value="#{document1.CategoryC}" rendered="#{javascript:!document1.isEditable()}">
                </xp:text>

            </xe:formRow>
            <xe:formRow id="formRow8" label="Sub Category:" rendered="#{javascript:document1.isEditable()}">
                <xp:inputText id="inputText7" value="#{document1.SubCategoryC}" rendered="#{javascript:document1.isEditable()}" readonly="true">
                <xp:this.defaultValue><![CDATA[#{javascript:parentDoc.getItemValueString("SubCategory");}]]></xp:this.defaultValue></xp:inputText>
            </xe:formRow>
            <xe:formRow id="formRow1" label="Sub Category:" rendered="#{javascript:!document1.isEditable()}">
                <xp:text escape="true" id="SubCategoryV" value="#{document1.SubCategoryC}" rendered="#{javascript:!document1.isEditable()}">
                </xp:text>

            </xe:formRow>
            <xe:formRow id="formRow2" label="Quarter / Year:" rendered="#{javascript:document1.isEditable()}">
                <xp:comboBox id="comboBox1" value="#{document1.ComQtr}" style="margin-right:10.0px" rendered="#{javascript:document1.isEditable()}">
                    <xp:selectItem itemLabel="Q1"></xp:selectItem>
                    <xp:selectItem itemLabel="Q2"></xp:selectItem>
                    <xp:selectItem itemLabel="Q3"></xp:selectItem>
                    <xp:selectItem itemLabel="Q4"></xp:selectItem>
                </xp:comboBox>
                <xp:comboBox id="comboBox2" value="#{document1.ComYr}"
                    rendered="#{javascript:document1.isEditable()}"
                    style="width:58.0px">




                    <xp:selectItems>
                        <xp:this.value><![CDATA[#{javascript:var profDoc:NotesDocument = database.getProfileDocument("configdoc","");

return
profDoc.getItemValue("cfgCYear");}]]></xp:this.value>
                    </xp:selectItems>
                </xp:comboBox>
            </xe:formRow>
            <xe:formRow id="formRow3" label="Quarter / Year:" rendered="#{javascript:!document1.isEditable()}">
                <xp:text escape="true" id="QtrYr" rendered="#{javascript:!document1.isEditable()}"><xp:this.value><![CDATA[#{javascript:document1.getItemValueString("ComQtr") + " " + document1.getItemValueString("ComYr")}]]></xp:this.value></xp:text>

            </xe:formRow>
            <xe:formRow id="formRow4" label="Date:">
                <xp:inputText id="inputText2"
                    value="#{document1.ComDt}">
                    <xp:this.converter>
                        <xp:convertDateTime type="date"
                            dateStyle="short">
                        </xp:convertDateTime>
                    </xp:this.converter>
                    <xp:dateTimeHelper></xp:dateTimeHelper>
                </xp:inputText>
            </xe:formRow>
            <xe:formRow id="formRow5" label="Activity">
                <xp:inputTextarea id="inputTextarea1"
                    style="width:413.0px;height:84.0px" value="#{document1.ComActivity}">
                </xp:inputTextarea>
            </xe:formRow>
            <xe:formRow id="formRow6" label="Comments:">
                <xp:inputRichText id="inputRichText1" value="#{document1.ComComments}"></xp:inputRichText>              
            </xe:formRow>
            <xe:formRow id="formRow7" label="Edit Policy Information:">
                <xp:checkBox text="Edit" id="checkBox1" value="#{document1.EditPol}" checkedValue="Edit"></xp:checkBox>

            </xe:formRow>
        </xe:formColumn>

    </xe:formTable></xp:panel>
                    </xp:panel>
                </xp:panel>
            </xp:panel>
        </xp:this.facets>

    </xc:AppLayout><xp:this.navigationRules><xp:navigationRule outcome="xsp-failure" viewId="/communications.xsp"></xp:navigationRule></xp:this.navigationRules></xp:view>
Naveen
  • 6,786
  • 10
  • 37
  • 85
Jim M
  • 177
  • 1
  • 15
  • 2
    You have the right in he ACL to create documents? – stwissel Feb 06 '13 at 04:39
  • 1
    That's a lot of stuff for a code sample. If your ACL is OK I suggest you try to reproduce the issue with minimal amount of elements and code. – Panu Haaramo Feb 06 '13 at 08:00
  • 3
    What if you change the default action on the data to create new document instead of openDocument. What happens then? – Simon O'Doherty Feb 06 '13 at 08:05
  • 1
    Please check on your console if there are any errors thrown. I could be that the computewithform is generating some sort of error which is not displayed to the user. Also add a general error control to the top of the page. – jjtbsomhorst Feb 06 '13 at 10:59
  • Please ignore this if irrelevant, I didn't fully comprehend the example… I have seen that when saving a new document and trying to get the parentID, the code getParentId() returns the NOTEID but when saving an existing document the same call returns UNID – Mikael Andersson Wigander Feb 06 '13 at 21:22
  • Issue update. I checked all of the suggestions listed above. The ACL is fine, I reduce the elements down to one, tried changing the default action, no errors on console, added error control, no errors on the page. What I did discover is that if instead of creating the document as a response, I create the same document/form as a standard new document and it saves fine. If I create as a response, it does not save the new document – Jim M Feb 06 '13 at 21:29
  • @Mikael that maybe the issue. Being new to xpages this is the first time I have attempted a response document. Is there a better way to do it that the method I am currently using? – Jim M Feb 06 '13 at 21:57

1 Answers1

1

This is solved. Unlike classic notes development, if the form property is set to document rather than response it will not save a document when using the action create response. So changing the property to a response solves the issue.

Jim M
  • 177
  • 1
  • 15