Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

importData() function

Avatar

Level 2

I have an xml file that I import successfully into a pdf.  However, if I have either:

     1. Updated the pdf that I import into and removed a field OR

     2. Have another pdf that has most (but not all) of the fields in the imported xml file

The submitted data will have the data that's on the xml, but also will have the data from the removed field or the other pdf.  From my limited understanding, this data is in the DOM.  What I want to do is:

REMOVE THE NODE/FIELD FROM THE XML FILE TO MATCH WHAT THE CURRENT PDF HAS.

I've tried, or thought of....

saveFilteredXML - not sure what a manifest is, help doesn't elaborate
remove - always fails to remove the node
xdpContent - this is a string of some kind, but help doesn't elaborate
loadXML
executeType
applyXSL

Any direction at all would be most helpful.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

The form design ..the PDF.

Paul

View solution in original post

16 Replies

Avatar

Former Community Member

If the imported data has those nodes in it then when you export the data the nodes that were not used will also be carried along. You would have to eliminate the data nodes in the imbound XML.

Paul

Avatar

Level 2

OK, but do you have any suggestions on how to eliminate the data nodes in the inbound XML?  I've tried remove, but that always fails.

Avatar

Former Community Member

If you are doing it inside of the form by then it is too late. Your best bet is to modify the XML before the merge using a style sheet. Can the application that is generating the XML be modified to stop generating this node?

Paul

Avatar

Level 2

The .xml is on an end user's PC - they click a button on the blank .pdf, and the xfa.host.importData(""); command is fired. Is there any way to assign this style sheet during the importData function?  Or should another function be called where I have more control over the incoming data?

Avatar

Former Community Member

How was the xml generated in the 1st place?

You do not have a means of applying the style sheet from that command nor is there a command to apply a style sheet from Reader or Acrobat.

Paul

Avatar

Level 2

I have a button that an end user clicks on that has this code - xfa.host.exportData("",0)

Avatar

Former Community Member

So if the field does not exist then it will not be part of the datafile. Also if you have to have the field then you can set the binding to None and it will not b eincluded in the data that is exported.

Paul

Avatar

Level 2

Tragically, LiveCycle (or maybe the reader itself?  Not a clue) thinks that all the data imported from the .xml should remain (this is data from the XML Data DOM, I think) regardless of whether I've bound or not - so on submit, it remains (as useless fields/data) on the form - in the background somewhere.  When you said the following - "Also if you have to have the field then you can set the binding to None and it will not b eincluded in the data that is exported." - if I were to explicitly set a useless node to binding=None, would that remove the data from the DOM?  Or no?  If yes, then how can I do that?

Avatar

Former Community Member

If the data that you are importing already has nodes that are not used, then they will be carried forward when you export. If you want to get rid of the data then you have no choice but to start with a data file that does not have those nodes in it. So I would create the form the way you want it, then export fresh data and use that going forward.

Paul

Avatar

Level 2

That is not an option.  There must be some way to remove the imported unused nodes.  Can I write a parser somehow?  Why won't the nodes.remove function work?  Or saveFilteredXML (even though I have no idea what a manifest is, nor is help helpful).  Or loadXML?  Or applyXSL?

Avatar

Former Community Member

The remove nodes should work but it is tricky. If you post your form and indicate which nodes you want to drop I can give it a try.

The applyXSL will only run serverside and the saveFilteredXML will require a manifest object that will take as much time to create as getting the removeNode to work.

Paul

Avatar

Level 2

I'm assuming that when you say post, I should attach the xml file - I've paired it down quite a bit (it's kinda long!), and changed some field names.

The fields I would want to remove include....

<AuthNumber>
<billingMailAddr>

<hasPatientReached>
- <hasPatientReachedSubform>

- <NSLSubform>
- <NSLBPSubform>
    <NSLBP />
    <NSLIP />
</NSLBPSubform>
<NSLFindings />
<NSLIPExp />
</NSLSubform>

I realize this is quite a few, but even if you show me 1 or 2 examples, that would be great.  Also, just to confirm your response, this would get rid of the "unused" nodes, and I won't see them anywhere (like on submission), right?  With the saveFilteredXML, what is a manifest, anyway?

Avatar

Former Community Member

Looks like the system is messing with the attachments again ....can you post the XML and the template to livecycle8@gmail.com?

Thanks

Paul

Avatar

Level 2

Sure - just sent it.  Actually, I'm not sure what you mean by the template

Avatar

Correct answer by
Former Community Member

The form design ..the PDF.

Paul

Avatar

Level 2

Gotcha.  I just sent the .pdf and the .xml.

Sorry, the fields to remove are....

<billingMailAddr>
<hasPatientReachedMMI>
- <hasPatientReachedMMISubform>
- <NSLSubform>
- <NSLBodyPartSubform>
    <NSLBodyPart />
    <NSLImpairPct />
</NSLBodyPartSubform>
<NSLFindingsTestResults />
<NSLImpairPctExplanation />
</NSLSubform>

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----