Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Help detecting a blank form

Avatar

Level 7

I need a way to determine if the form is blank. I have a project and the customer wants one of two scenarios. If the form is 100% blank, no data of any kind in any field, then the want to print it one way. However as soon as a field (any field) has any data in it then it will be printed a different way.

I have tried using event.target.dirty unfortunately any change and the form is marked dirty so this would not work.

My thought is to cycle through all fields and look for a value > null. If I return anything other then null then the form would print as a filled form.

Any help would be greatly appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is a progress tracker form, where the script does two things:

  • first it counts the total number of objects and then,
  • it looks at whether the objects have a value of not.

https://acrobat.com/#d=1Evwijur*lEdxMmlWClE7g

As a progress tracker it is not very good, because the function is called from the layoutReady event. This is because as new objects are added, the total counter needs to be updated.

This was adapted from Paul Guerette's LockAllFields example.

You could adapt this just to loop through your form. You would call the function from the click event of the print button, so it would be reasonably efficient, as it would only fire when needed.

Hope that helps,

Niall

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

Here is a progress tracker form, where the script does two things:

  • first it counts the total number of objects and then,
  • it looks at whether the objects have a value of not.

https://acrobat.com/#d=1Evwijur*lEdxMmlWClE7g

As a progress tracker it is not very good, because the function is called from the layoutReady event. This is because as new objects are added, the total counter needs to be updated.

This was adapted from Paul Guerette's LockAllFields example.

You could adapt this just to loop through your form. You would call the function from the click event of the print button, so it would be reasonably efficient, as it would only fire when needed.

Hope that helps,

Niall

Avatar

Level 7

Niall

This is exactly what I need. I am trying to narrow it down though to just the tracking part of the form. I do not need the progress bar on the form. I will sift through and figure out the part I need.

Thanks so much for your help,

Mike

Avatar

Level 10

The function should still do the trick, with some adjustment. When you call the function, don't pass the name of the root node 'form1'. Instead pass the name of the subform for the part of the form that you want checked.

Niall

Avatar

Level 7

I can get the objects to complete to work but for some reason I cannot get the total objects to work.

Avatar

Level 7

I got it to work. Its awesome thank you very much for all your help