How can i get data from another document when i creat a new document on my XPage? - xpages

I've start to develop XPage 7 weeks ago, and i have a problem with "getting data".
On my first page i have a view with a lot of documents, and a button who redirect me on a new page, to create a new document. On my first page i can select a document and when i click on the button i put my id document selected on a sessionSCope.
Button script:
var viewPanel=getComponent("viewPanel1");
var docIDArray=viewPanel.getSelectedIds();
var docUID=database.getDocumentByID(docIDArray[0]).getUniversalID();
sessionScope.put("docUID", docUID);
context.redirectToPage("AjoutSuivi");
On my new XPage i want to get some data on my selected document so on clientLoad of the XPage i execute this script:
var docUID = sessionScope.get("docUID");
var doc:NotesDocument = database.getDocumentByUNID(docUID);
getComponent("contactname1").setValue(doc.getItemValueString("ContactName"));
On my database i have a field "ContactName" and on my XPage i have a field contactname1. I have try with "database.getDocumentByID(docUID)" and i'm sure that "database" is the good link of the database.
When i try it, there is nothing on the field contactname1 have u an idea why that's doesn't work ?
So much thank's if you can help me
Yann
PS: sorry for my bad english

Put your code into the event afterPageLoad and it should work (for the execution order of events take a look at XPage Cheat Sheet #1 - The Page Lifecycle).

Y4nn welcome to the XPages club. When you bind a control to a data source it is better to set the value in the data source than in the control. So you write:
document1.getDocument().replaceItemvalue(...)
(picking on a glass now, watch out for correct syntax)

Related

How to create in XPages a submit button to discard the current and create a new document?

I need to create a link on a XPage to refresh the panel with a new document.
The current document must not be saved.
Thank you!
Just create a link with the URL to the page where this link is on, e.g.
<xp:link text="Discard and start over" value="/thepage.xsp?action=newDocument"></xp:link>
you can reinstatiate a data source bound to a panel using the following code. Try running that before you submit.
var c = getComponent("mypanel");
var ds = c.getData();
ds.get(0).refresh();

A form link in a document - Domino Designer

A document is where you can view the details .
And a form is something like a document where you can put inputs, choose whatever you want in a dropdown, fill up textfields and etc.
How can I put a link that will redirect to a form, and can be filled up?
Do I need to use appendDocLink?
And I'm very new to Domino Designer, please bear with me.
Add a Button, Action, or hotspot to your form, and give it a formula like this:
#Command[Compose];"": ""; "TheNameOfYourFormGoesHere");
You can find the syntax of the Compose command here.
I recommand not explaining what a form or a document is, but only ask you question...
In order to responde to your question tel us "where you want to put a link" (web / notes client ?)
You don't need appendDoclink.
Look at http://www.ibm.com/developerworks/lotus/library/ls-Domino_URL_cheat_sheet/ you can make a (web) link to "redirect" user to create a new document = fill a form : http://Host/Database/FormName?OpenForm

Opening different xpages forms from a view panel

I have an Xpages application that pulls data from another .nsf file. I have a view panel linked to a view in that db. The view has documents with several different forms in it. I want to be able to open each document in it's own form(xpage).
How do I write a computed At Runtime, open selected document using: statement that will select the correct Xpage to present the document.
If you use the Data View component instead of a View Panel, you can compute the pageName attribute, referencing the var attribute to return a different value for each row based on the document that row represents. The flexibility of the Data View component also makes it easier to make your app look more like a modern web application and less like an Excel spreadsheet. As an additional bonus, the mobile theme invokes a renderer that makes each Data View instance look like a native mobile list, so using Data Views instead of View Panels simplifies mobile development.
You have 2 options:
use "use xpage associated with form" and edit the form's property
use a SSJS formula to compute the Form. You provide a variable name in the view control var to access a view row as XSPViewEntry. If the Form is in a view column even one you don't display you use .getColumnValue otherwise getDocument.getItemValueString
Does that work for you?
Maybe this mothed can help you: Unable to get document page name for
Hope this helps
Mark
I had a similar problem today. I use only one form but 3 different xpages for associated with this form. I have 3 different document types in the view. I used rowData the get the type of the document.
try{
var v=rowData.getColumnValue("form");
if(v.indexOf("x")> -1){var page ="x.xsp"}
else if(v.indexOf("y") > -1){var page = "y.xsp"}
else{var page = "z.xsp"}
}catch(e){
var page = "x.xsp"
}
So to your view you can create a column with the value of the form and you can use it.
I have used the extension library Dynamic View control which has an event you can code to get a handle to the NotesViewEntry which was selected. See the demo database page Domino_DynamicView.xsp and the Custom Event Handler tab for an example.
Note, in 8.5.3 (I have not upgraded yet) if you add or edit the eventHandler for onColumnClick it will be added to the XPages source as an xe:eventHandler. It needs to be an xp:eventHandler to work. The way to do it is to copy the code in the source from the exiting event and delete it. Recreate the event and update the code. Then go back into the source and change the tags within the eventHandler to xp:.

Multiple data sources in XPages

I have 2 xpages that interact together. The first acts as a homepage and allows the user to create a new document and fill out some basic header information. The button to create the new document, sets a sessionScope var with the NoteID. It then saves document1 and opens the same document using another xpage.
The second xpages is bound to document1, and uses the sessionScope to edit the document. This xpages contains and editPanel bound to document2. I want to create a child document to document2. This works but what happens is document1 is also saved as conflict. It is also saved as a second main document.
I DO NOT want to save document1 at all, but can't seem to prevent it. The button that creates document2 uses the simple action save document, and specfies document2.
HELP, I have tried everything, and have been stuck on this for 2 days.
Thanks!
Steve
To bind to multiple datasources, on your XPage, under Properties expand Data and set "Ignore Request Params" to TRUE
If you change the type of your buttons, to a simple button instead of a submit button, and handle the doc.save() yourself should solve your problem.
The Save Document simple action accepts the name of the data source to save as a String argument. If supplied, it will only save that specific data source.

Action (button) to open an existing form

I have created a view which displays some informations.
Also, on top of view I created an action bar containing 2actions: New entry & Delete entry. There is also a form called 'formmain', where I have some fields & listboxes where I insert the informations that will appear on the view.
What I want to do and I ask for your help: I want when i click the action button 'New entry', the form called 'formmain' will open/be displayed. Thank you!
You can use the #Compose Formula command for this. Here's an example for your specific form:
#Command([Compose]; ""; "formmain")
I will recommend that you take a look at the Lotus Domino Designer Help database which is part of your Notes installation. It has a lot of useful information including code examples.

Resources