Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Export XML to local path; Completeness check

Avatar

Level 2

A couple of questions as we're wrapping up development on our form-

First, I'm attempting to build a button that will save the exported XML to a local path, ie, c:\\windows\desktop

I found this: xfa.data.saveXML(); which I put in the click event, but how do I tell it to save to a path?  (and while we're at it, specify a file name)

Alternately I tried using the built in buttons -email, HTTP, but I've been unable to find documentation on how to construct the code.  I know just about anything can be added to the XML source, but I need a pointer on what the best way to handle this is, and how to construct the instructions to save the path.  This is for our administrators to extract the XML and import it into their database.

Second question, What is the best way to allow a user to do a completeness check?  I like how the email submit button by default checks all the fields set to "user entered required" and would like to configure a button that similarly performs a completeness check and then either alerts the user that there are fields left, or confirms that the form is complete, perhaps with instructions on what to do next.  What is the best way to handle this?  The plan for submittal is the user will save the pdf locally and then upload it manually to a server that requires a login, then the administrators will export the XML file and import it into a database.

Thanks for your insight..

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

1. You cannot include a path or filename in that statement (unless you certify the document which has issues of its own). The user must select the path and filename (for security reasons). By default it will save the data in an XDP format. You can pass another parameter which will save the file with an xml extension instead.

xfa.host.exportData("", false)

2. Just add a regular button and add code to the click event that will run all of the validations for the form. Assuming that the root node of your form is form1:

form1.execValidation()

This will return a true or false value depending on whether there are validation errors or not. So you coudl combine this with an if statement:

if (form1.execValidate() == true){

     //code to cause the submit to happen

     submitButtonName.execEvent("click")

} else {

     app.alert("There are validation errors in your form!")

}

You woudl hide the real submit button in this instance so the user could not bypass your code.

Hope this helps

Paul

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

1. You cannot include a path or filename in that statement (unless you certify the document which has issues of its own). The user must select the path and filename (for security reasons). By default it will save the data in an XDP format. You can pass another parameter which will save the file with an xml extension instead.

xfa.host.exportData("", false)

2. Just add a regular button and add code to the click event that will run all of the validations for the form. Assuming that the root node of your form is form1:

form1.execValidation()

This will return a true or false value depending on whether there are validation errors or not. So you coudl combine this with an if statement:

if (form1.execValidate() == true){

     //code to cause the submit to happen

     submitButtonName.execEvent("click")

} else {

     app.alert("There are validation errors in your form!")

}

You woudl hide the real submit button in this instance so the user could not bypass your code.

Hope this helps

Paul

Avatar

Level 2

Thanks so much for your help so far, Paul

Everything works great, except when trying to use the Export button from Reader.  (It works as expected in Pro)

The file has been reader extended, so save works, but our developers need the ability to click that Export button from Reader and get an XML file.  Any ideas if this is possible or how the code can be tweaked so it will work for Reader?

Thanks!

Avatar

Former Community Member

The ability to export data from Reader is a Reader Extensions option that is only available in the server version of the LiveCycle Reader Extensions server. You would have to look into that to accomplish what you want.

Paul

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] ----