Hello,
I have been working on a form in LiveCycle Designer ES2 that is intended to do the following:
1. The User enters the first value (like an ID or a name) in the row of a table of text fields
2. A Script searches an underlying database which will match the entered value and fill the rest of the row
But I have absolutely no idea how to add databeses to livecylce and access them. I want to use XML-databases (exported from Excel) and then use javascript to access them - is this possible?
The databeses would be locally on the computer.
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
You can create a dataset with code, which might be the best approach for you. So in the forms initialize event you could have some code like;
var namesXML = <Root>
<Row>
<Name>Lederarmschienen</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>1</LA>
<RA>1</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.1</gRS>
<gBE>0.1</gBE>
<Gew>1</Gew>
<Preis>15</Preis>
<Slot>Arm</Slot>
<Typ>Leder</Typ>
</Row>
<Row>
<Name>Plattenarme</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>5</LA>
<RA>5</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.5</gRS>
<gBE>0.5</gBE>
<Gew>3</Gew>
<Preis>200</Preis>
<Slot>Arm</Slot>
<Typ>Platte</Typ>
</Row>
</Root>;
var names = xfa.datasets.createNode("dataGroup", "Root");
names.loadXML(namesXML.toXMLString());
xfa.datasets.nodes.append(names);
I'm using an E4X literal here to make it easier to cut and paste. Also note that the top element in the XML will be replaced by the name in the second parameter of the createNode method (so easiest thing is to keep them the same)
Then you can reference this in code, so maybe in the exit event of the name field (TextField1 in the code below) you could have the following code to populate other fields;
var row = xfa.datasets.Root.resolveNode("Row.(Name.value=='" + TextField1.rawValue + "')");
if (row !== null)
{
Ko.rawValue = row.Ko.value;
Preis.rawValue = row.Preis.value;
Slot.rawValue = row.Slot.value;
Typ.rawValue = row.Typ.value;
}
I personally prefer this approach but since I started using E4X I should probably point out that we could also use E4X to process the XML, so this does the same thing.
var row = namesXML.Row.(Name==this.rawValue);
if (row.length())
{
Ko.rawValue = row.Ko.toString();
Preis.rawValue = row.Preis.toString();
Slot.rawValue = row.Slot.toString();
Typ.rawValue = row.Typ.toString();
}
Here is a link to the form I used to check my code, https://acrobat.com/#d=yCY7Hi15yg7yVWFbslkXmw
Hope it helps
Bruce
Views
Replies
Total Likes
Hi,
If you have an XML file you can create a data connection with it from the Data View tab. Then you can use JavaScript to reference the values, but this script would be very specific to your xml. If this sounds like what you want to do then if you post a little bit of your xml I'll write enough code to get you started.
Regards
Bruce
Views
Replies
Total Likes
Hello,
Thanks for the Answer!
Yes, this sounds like what I need. But I need more than one XML Database and LiveCycle refuses to let me make more than one data connection to xml-files. Is there a workaround for that?
My first xml:
The Table in the pdf will look very similar, so I imagined the javascript to be something like this (on the click of a button):
What do you think, will this work?
Views
Replies
Total Likes
You can create a dataset with code, which might be the best approach for you. So in the forms initialize event you could have some code like;
var namesXML = <Root>
<Row>
<Name>Lederarmschienen</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>1</LA>
<RA>1</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.1</gRS>
<gBE>0.1</gBE>
<Gew>1</Gew>
<Preis>15</Preis>
<Slot>Arm</Slot>
<Typ>Leder</Typ>
</Row>
<Row>
<Name>Plattenarme</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>5</LA>
<RA>5</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.5</gRS>
<gBE>0.5</gBE>
<Gew>3</Gew>
<Preis>200</Preis>
<Slot>Arm</Slot>
<Typ>Platte</Typ>
</Row>
</Root>;
var names = xfa.datasets.createNode("dataGroup", "Root");
names.loadXML(namesXML.toXMLString());
xfa.datasets.nodes.append(names);
I'm using an E4X literal here to make it easier to cut and paste. Also note that the top element in the XML will be replaced by the name in the second parameter of the createNode method (so easiest thing is to keep them the same)
Then you can reference this in code, so maybe in the exit event of the name field (TextField1 in the code below) you could have the following code to populate other fields;
var row = xfa.datasets.Root.resolveNode("Row.(Name.value=='" + TextField1.rawValue + "')");
if (row !== null)
{
Ko.rawValue = row.Ko.value;
Preis.rawValue = row.Preis.value;
Slot.rawValue = row.Slot.value;
Typ.rawValue = row.Typ.value;
}
I personally prefer this approach but since I started using E4X I should probably point out that we could also use E4X to process the XML, so this does the same thing.
var row = namesXML.Row.(Name==this.rawValue);
if (row.length())
{
Ko.rawValue = row.Ko.toString();
Preis.rawValue = row.Preis.toString();
Slot.rawValue = row.Slot.toString();
Typ.rawValue = row.Typ.toString();
}
Here is a link to the form I used to check my code, https://acrobat.com/#d=yCY7Hi15yg7yVWFbslkXmw
Hope it helps
Bruce
Views
Replies
Total Likes
Thanks alot, that worked !
Views
Replies
Total Likes
Views
Likes
Replies