Expand my Community achievements bar.

calculate events running on server

Avatar

Former Community Member

I have an large XDP tempate. All fields are set to RunAt Client. Two fields, a checkbox and date field, which aree bound to an XSD schema, have have commented out script (using /*...*/) in the calculate event. The fields retain their values after the form is Submitted as a PDF (I have verified this using Stefan Cameron's "echo" url). However, the Forms Server seems to attemt to run the calculate event and blows the values of the fields away.

Although I can fix the problem by removing the commented script, I have 2 questions:

1)     I dont really understand why the Server is running the calculate event when I have "RunAt" client. However, The manual does say, "Scripts in forms designed for printing run at the server even when you set the scripts to run at the client."

        What does it mean by, "a form designed for printing"? How is that set?

2)     Why does commented out script have such an affect?

thanks

6 Replies

Avatar

Level 5

Not sure, but I am assuming you have Form Requires Server-side Data Binding and/or Scripting option set in File->Form Properties. This will tell Form server to execute server-side code for objects which require binding updates and or scripting. When form server is looking for code to execute on the server side, it looks for any value in the scripting node of your object within the xdp. Even if it is only a comment. Although Im not sure why the values are not being preserved other than maybe the script engine is expecting you to set a value in the calculate event. There are other places to turn this on as well (for example through the API), but the form properties one is the default.

I believe the designing for print thing refers to building forms for use with Output ES where, there is usually no client interaction and forms are rendered and printed without a client, so the server will act as the client and execute scripts set to client on the server.

Avatar

Former Community Member

thanks, that was helpful.

With some forms, we prepopulate a few basic fields when the form is first rendered, e.g. name and address, so we have always checked, "Form Requires Server-side Data Binding". However, we don't really want it to do any calculate event script execution, only merge FormData with the XDP. I assume that unchecking the "Form Requires Server-side Data Binding" would prevent this process???

Avatar

Level 5

Yes it would be needed when you are binding and populating/scripting data population. What are you using to call Form server with? API?

Avatar

Former Community Member

To render the form, we send FormData and XDP TemplateName by http Post. This is unpacked by a Java function which calls Form Server APIs to render the form.

Avatar

Level 5

Not tried it, but you could set the FormModel in RenderOptionsSpec to "client" and see if it would work. I will see later if i can duplicate what youre getting. Only other way would be to remove comments or add a $.rawValue = $.rawValue to the end of the calcs

Avatar

Former Community Member

thanks for that. I must admit, I dont really understand why the options, "Form Requires Server-side Data Binding and/or Scripting" results in server side scripting when all my Form objects are set to "RunAt" Client