Add fields dynamically

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner

Add fields dynamically

Hello,

Is it possibe add dynamically field to a APS form using javascript events.

My need is the following:

I have a form that contains people field (validator1). Once the user fill this field we want to add dynamically another people field (validator2) in the form. Once the user fill validator2 field we want to add dynamically another people field (validator3) in the form...

Best Regards,
Makram

2 Replies
Highlighted
Senior Member

Re: Add fields dynamically

You can use visibility condition for the field, if validation1 if filled show the second validation2 and so on.  

Highlighted
Partner

, Re: Add fields dynamically

Yes, you can do this using javascript. The bad news: it is cumbersome.

Basically you need to manipulate the form definition from javascript. The best way to do it is by listening to the FormRendered event which passes the AngularJS scope and form. You have to create the JSON for containers and fields and pass all your generated fields into

scope.allFormFields

Then, you need to pass your containers (in case you add a new container) to

form.fields

or simply to the column of an existing container (in case you don't create a container of your own to hold the fields). Anyways make always sure, that your generated JSON is correct.

Also, this approach does not support saving the form (at least not your dynamically added fields). To do that, you will need some hack to accieve this, like saving all properties into a hidden text field that holds all your values or manually use task variables which are also not that easy to do...

 

Good luck!

Manuel