Expand my Community achievements bar.

Setting TextField presence post submit

Avatar

Level 1

Hi there.

I'm working on documents for an IT company, and while doing so I have stumbled across a couple of problems that I hope to get help with.

We're using Static PDF Forms (xdp), that are produced via the server (livecycle I guess) and then opened and edited by the client and saved via a Save/Submit button at the top of the document. The form is submitted to the server when this button is pressed, it is not saved on the client computer.


1) Floating fields that are editable.

I was able to solve this by attaching a script object that looks for {token}'s inside a TextField, and replacing these with their equivalent records that are being merged in to the document when the document is first created. This script is invoked by each TextField that needs this functionality during the TextField::initialize event. This works fine, but perhaps there's a better solution?


2) Removing empty TextField/Text elements from the form

I am having some trouble implementing this. In theory, all I need to do is a simple check;

function removeIfEmpty(ptr) {

    if(ptr.rawValue == " ") {

        ptr.presence = "hidden";

    }

}

This function works fine when previewing in the PDF Previewer inside of Adobe Designer, but I can't figure out which event to attach this script to (for each TextField/Text) so that it works for the client. The idea is that the client might not need all TextField's, and after producing the initial document via the server, the client can open the document and erase content from the TextFields. The Client is unable to completely empty the TextField, if they do so the TextField is re-populated (perhaps it doesn't get saved) upon re-opening the document. If they do however leave a " " (space) it saves fine.

My question to you regarding 2 is where I can do my removeIfEmpty() check. Since we're using static PDF forms for now, I can't edit the layout post-render. Perhaps I can attach the script to the TextField::change or the like, and when the form is submitted the presence is submitted with it? However, because of the static PDF form it might be possible that the TextField is excluded from the layout and thus moving other elements up, which is exactly what we need this functionality to counter.

I have tried attaching it to each TextField::initialize, TextField::form:load etc, but those events does not seem to be invoked upon re-opening (only during the initial production of the document on the server).


--

Hope someone has input on this.

4 Replies

Avatar

Level 10

Hi,

The only thing I can see is that the form is static and would need to be saved as dynamic for show/hiding objects.

The docReady event is worth considering because it only fires once when the form is rendered, whereas initialize can fire several times.

If you have problems with the form keeping changes, check that that "Automatic" is selected in the File / Form Properties / Defaults / Preserve scripting changes.

Good luck,

N.

Avatar

Level 1

Hi and thanks for your reply.

I'm unable to use Dynamic XML Forms as of now, so it's important that all changes happen before layout:ready. I'm not sure if docReady would work, since the layout has already been sorted and the form is being displayed in the client application / browser.

Since I need presence = "hidden" to affect the actual layout of the document, I need to make sure it is invoked before that process begins, thus I decided to go with Initialize. Perhaps form:ready would be better for the data insertion in to editable text fields?

--

Concerning the presence; Is the document re-rendered upon submitting to the server? If it is, it should be possible to hide textfields. The idea isn't to hide the textfield in the client that the user is using, but to let the user; Remove text from textfield, insert space (" "), submit the form, then open the form again with the "empty" TextField hidden from the layout.

Is that possible? Or can this only be done during the initial production of the document on the server?

Avatar

Level 10

Hi,

I don't have experience in the server side of this, to be of much help to you.

It looks like you want to capture the layout before the layout process is completed:

Windows 71.png

I still think you may have issues trying to get this to work with a static XFA form, albeit that you are trying to change the layout before it is rendered to the user. Hope that someome can help you out with this.

Good luck,

Niall

Avatar

Level 1

Thanks Niall.

I've finally got it working, after shedding a whole lot of blood, sweat and tears.

This is what I've found so far;

The removeIfEmpty() script works ( user removes all text, types in a space and submits to server, the re-open ) as:

JavaScript Server - form:ready -- No

JavaScript Client - form:ready -- Yes

JavaScript Server - initialize -- No

JavaScript Client & Server - validate - Yes

So from what I gather, I am perhaps better off leaving the script execution up to JavaScript Client - form:ready.