Question: i have an issue that it gives me some headache lately.

In my XPage there is a view displaying some docs ( let say `Pdoc` as datasource ) and I open/create them inside a `<xe:dialog>`. This dialog has only `Pdoc` declared as datasource, and it inherits some values from the Xpage datasrouce. My clickable column formula is:

```
// some var declarations
var formName = rowData.getDocument().getItemValueString("Form");

if ( formName == "fmP" )

{ viewScope.put("dlgDocUnid", pe.getUniversalID())
getComponent("exampleDialog").show(); }

```

On the same XPage, I can create a new `Pdoc` using the same dialog via a button, `New Pdoc`.

The problem is: when I opened an existing `Pdoc` and then just save it or close it, and after I use the button to create a newNote => the old / previous ( already saved `Pdoc` ) is showed...

If firstly I just created a new note `Pdoc`, it works, and it is showing a new empty `Pdoc.`

My dialog data code:

```
<xp:this.data>
        <xp:dominoDocument var="Pdoc" formName="fmPersContact"
            ignoreRequestParams="true" scope="request" action="editDocument">

            <xp:this.documentId><![CDATA[#{javascript:viewScope.get("dlgDocUnid");}]]></xp:this.documentId>
        </xp:dominoDocument>
    </xp:this.data>

```

I use the `.documentId` for the open method from the viewPanel. I think here is the problem. I think ,( I'm not sure), I should compute this documentId in such way that when I create a newNote this documentID shouldn't be anymore the `viewScope.get("dlgDocUnid")`.
Thanks for your time.

Answer: 
If I understood correctly, you have defined two data sources within the XPage and you try to consume them in the dialog, right? Instead I suggest defining a single data source within a panel inside the `xe:dialog`.

I have blogged about a similar example. In this example, tooltip dialog has been used but it's the same logic, you might replace `xe:tooltipDialog` with `xe:dialog`.

<http://lotusnotus.com/lotusnotus_en.nsf/dx/mini-patterns-for-xpages-parameter-editing-with-dialogs-1.htm>

The idea here is that you use a `viewScope` variable named `noteId`. To open an existing document, set this variable to the note id of the existing document. To create a new document, the value will be set as `NEW`. Then you define the data source within the dialog according to this variable:

```
<xe:dialog>
 <xp:panel style="width:500.0px"> 
  <xp:this.data> 
    <xp:dominoDocument
        var="document1"
        formName="Parameter" 
        action="#{viewScope.noteId eq 'NEW'?'createDocument':'editDocument'}"
        documentId="#{viewScope.noteId eq 'NEW'?'':viewScope.noteId}" 
        ignoreRequestParams="true"> 
    </xp:dominoDocument> 
  </xp:this.data> 
 ..... Dialog content ....
 </xp:panel>
</xe:dialog>

```

When you put the data source **inside** the dialog, you don't refresh the page to load or prepare data sources before launching the dialog which is your current problem I guess.
Could it be that you forgot to deactivate the flag to ignore request parameters.
Sounds like the dialog is always associated with the current document instead of the parameters from the docid