cancel
Showing results for 
Search instead for 
Did you mean: 

Add fields dynamically

makram_baaziz
Champ in-the-making
Champ in-the-making

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 2

amruta_w
Star Collaborator
Star Collaborator

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

messmeister
Champ in-the-making
Champ in-the-making

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