How to calculate a field based on completion of required fields?

hy9fesh

13-05-2015

Is it possible to calculate a field as "Complete" or "Not Complete" based on completion of all the form's required fields?

For example, the form is is named "Form" and the subform is named "Subform." I was thinking of coding something in JavaScript, like the following:

if(Form.Subform.execValidate == false);

{

this.rawValue = "Not Complete"

}

else

this.rawValue = "Complete"

Yet, the above JavaScript doesn't seem to be working?

That said, I have a lot of required fields so I'd prefer not to list all of them. Please let me know if I'm on the right track!

Accepted Solutions (0)

Answers (7)

Answers (7)

hy9fesh

24-05-2015

Hi @BR001, it appears that your script works if the mandatory fields are not conditionally changing. I need something more specific. Thanks, though!

_Bruce_Robertson

MVP

19-05-2015

I see what you mean, seems the execValidate() method call cancels the calculate event.  Maybe you can try using the validationState event, which came in with Reader 9.1.  This event fires when a field changes from valid to invalid or vice-versa (it also fires after the initialize and if the reason for being invalid changes).  So you could put a validationState event at the top of you form (using event propagation) with the following code;

if(form1.getInvalidObjects().length > 0)

{

    subform.CompletionStatus.rawValue="Not Complete"

}

else

{

    subform.CompletionStatus.rawValue="Complete"

}

Here is a version of your sample that implements this, https://sites.google.com/site/livecycledesignercookbooks/home/form_sample.br001.pdf?attredirects=0&d...

Mandatory fields are only flagged as invalid once an attempt to submit has been made, or a call to execValidate() has been made (or when a field that had a value is cleared).  So I have added an execValidate() in the docReady event and also set the form validation properties to not show any error message popups.

Do you have to support earlier versions than 9.1?

hy9fesh

18-05-2015

Here you go @BR001. Thank you so much for looking into this. Note that the Completion Status is set at "Complete" for some reason, even though the required field has not been filled out:

form_sample.pdf - DocDroid

hy9fesh

18-05-2015

Give me a few minutes to mock a form up.

That said, I've placed the following code into the "calculate" event:

if(Form.Subform.execValidate() == false)

{

this.rawValue = "Not Complete"

}

else

this.rawValue = "Complete"

I want the field to show "Not Complete" or "Complete" based on the whether or not the required fields have been filled. It appears that I can't get this to work unless I put it on a "click" event of a button.