0
votes

I have two forms, Organisation and Contact. Contact is a response to Org, and each form has an XPage where the form can be filled in, saved etc. When opening edit_contact.xsp directly and creating a document (not as a response to an org), everything works fine.

On edit_org.xsp, I have a button with 2 events. The first copies some values into sessionScope so I can inherit them into the Contact. The second is a "Create Response Document" event which creates a new response with the parent ID being the current org document, and sends the user to edit_contact.xsp. Pressing the button changes XPage correctly and the field inheritance works fine, but pressing "Submit" on the Contact form doesn't save anything, and no document is created.

This exact same setup works 100% as desired in another database, I have no idea why it won't work properly here. Is there an obscure setting somewhere I am missing?

<xp:button value="Create Contact" id="button1" rendered="#{javascript:!document1.isEditable()}">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete">
    <xp:this.action>
        <xp:actionGroup>
            <xp:executeScript>
                <xp:this.script>
                    <![CDATA[#{javascript:var doc = document1.getDocument();

                    sessionScope.PFirstName = doc.getFirstItem("P_Firstname").getValueString(); 
                    sessionScope.PSurname = doc.getFirstItem("P_Surname").getValueString(); 
                    sessionScope.PFamily = doc.getFirstItem("P_Family").getValueString(); 
                    sessionScope.PDOB = doc.getFirstItem("P_DOB") 
                    sessionScope.PAGE = doc.getFirstItem("P_Age").getValueString();}]]
                </xp:this.script>
            </xp:executeScript>
                <xp:createResponse name="/edit_contact.xsp" parentId="#{javascript:document1.getNoteID()}">
                </xp:createResponse>

        </xp:actionGroup>
    </xp:this.action>
</xp:eventHandler>
</xp:button>`

Here is a link that shows what I am trying to do (minus the field inheritance):

http://min.us/mKSJED8tT

Currently the forms and views all work, but the document created with the "Response" form appears not to be a response document - it has no $REF field. This setup works perfectly in a different database - what is going on?

4
Can you share some code?Ken Pespisa
Are you perhaps having a validation issue but no xp:messages control to show the error messages? That could explain why "nothing" happens when you submit the form.Per Henrik Lausten
I noticed that you are calling the button on document1 and using doc for the response. DO you need to set IgnoreResponseParams to True?RoyRumaner

4 Answers

0
votes

It's hard to tell what might be happening without seeing any code. Since it works for you in another database, could it be an ACL issue? Where the user you're logging in as - possibly - anonymous - doesn't have the ability to create documents?

0
votes

Instead of "push" approach go for "pull" - just open response page with url parameter of parent document. In its postNewDocument event initialize field values from it.

0
votes

It would be useful to get an update on two key points made by others:

  1. Is ignoreRequestParams set on your response document datasource? If not, regardless of what you're trying to define for the second datasource, it's UNID etc are pulled from the request parameters. So both datasources are effectively the same datasource.
  2. Is it throwing a validation error? If so, nothing will be saved.
0
votes

There are two possible issues:

First the use of getFirstItem("x") is not a best practice. So:

sessionScope.PDOB = doc.getFirstItem("P_DOB") 

would be storing a NotesItem in the sessionScope which will not work. It is recommended to use:

sessionScope.PDOB = doc.getItemValueString("P_DOB");

Second the use of getNoteID() might not be returning what you want (Which is the UNID of the document). Use .getDocument().getUniversalID() instead.

<xp:createResponse 
     name="/edit_contact.xsp" 
     parentId="#{javascript:document1.getDocument().getUniversalID()}">
</xp:createResponse>

-edited- /Newbs