Form with different representation of the same data

borncreations

12-09-2018

Hi;

I am relatively new to LiveCycle but have a solid knowledge of JavaScript. We have an requirement where we need to display the same data using in different tables using different grouping. The challenge is that I cannot bind the same data twice in LiveCyle. Before spending too much going down an avenue that does not lead anywhere I like to validate my train of thought.

Assuming the the data xml looks something like

<TimeEntries>

     <Entry>

          <ServiceDate>1/2/2018</ServiceDate>

          <ServicePerformer>Tim Smith</Service Performer>

          <Hours>8</Hours>

          <Price>800</Price>

          <Role>Senior Consultant</Role>

     </Entry>

     <Entry>

          <ServiceDate>2/2/2018</ServiceDate>

          <ServicePerformer>Tim Smith</Service Performer>

          <Hours>8</Hours>

          <Price>800</Price>

          <Role>Senior Consultant</Role>

     </Entry>

     <Entry>

          <ServiceDate>8/2/2018</ServiceDate>

          <ServicePerformer>Tim Smith</Service Performer>

          <Hours>8</Hours>

          <Price>800</Price>

          <Role>Senior Consultant</Role>

     </Entry>

     <Entry>

          <ServiceDate>8/2/2018</ServiceDate>

          <ServicePerformer>Henry Smith</Service Performer>

          <Hours>8</Hours>

          <Price>800</Price>

          <Role>Senior Consultant</Role>

     </Entry>

</TimeEntries>

I need one table that provides the output grouped by Week, then Consultant and the total Price. Another table needs to have grouping by Week, then Role and the total Price. There are two more different groupings.

First I would need to alter the xml Data (via script) to include the week. Second I either need to clone TimeEntries (for each of the groupings required), or create new nodes with the aggregation done already.

Third step is to then bind the new nodes to a table on the form. Does this approach make sense and is this possible to achieve with the scripting available?

I have done some testing adding nodes to the data xml. Whilst I can see the node count changing, when I save the xml (xfa.host.exportData("", 0)) it does not show the new nodes in the export.

Any feedback is much appreciated.

Thomas

Accepted Solutions (0)

Answers (3)

Answers (3)

_Bruce_Robertson

MVP

14-09-2018

Hi Thomas,

If there is no user input you could create the input XML to suit the form structure you require, or you could use the XSLT option within Designer to create them.

Bruce

borncreations

14-09-2018

Thanks Bruce;

There is no user input, the form is merged with the data xml by a server application in our case SAP S/4HANA. This is a big learning curve for me to see what is possible and what not.

Will have a look at adding and updating the additional tables than directly from the script rather than binding them to the xml data.

Will also need to look at it form a performance point of view as I could have several thousand entries in the source data.

Will look the $data.saveXML("pretty") command.

Regards

Thomas

_Bruce_Robertson

MVP

14-09-2018

Hi Thomas,

I think I would do this with a calculate event, with some script that would generate the other tables in the form DOM.  I would use the calculate event so it would fire whenever there's a change in the source data, or is this more of the report being generated than a form being filled in.

If you generate the required elements in the data DOM (which sounds like the current plan?), you will have to call the remerge() method to re-generate the form.  This has the effect of resetting any other changes made by script, so can be fiddly to get working as needed.

But if you do want to update the data DOM, there is an example of "Creating a node in the data model" in the Designer scripting reference.

You might also find $data.saveXML("pretty") a more convenient way of looking at the contents of the data DOM.

Hope this helps

Bruce