Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Inserting a subform between two other subforms at runtime

Avatar

Level 1

I'm creating a form which will allow users to create a list of steps to perform a Job. I want to create the form so that they can insert a step between two other steps and delete any step they choose. I'm not familiar enough with the programming and when I write the script to add an instance, all it does is add it to the bottom of all my subforms rather than between my subforms. Also, I am limited to using livecycle designer 7.0.

I've put a link to the document below:

https://docs.google.com/fileview?id=0B4e5wvxbSBnKZGQ0N2I5NmMtY2FlMi00YTlmLWEwNjMtZjA0NTMwNmY0N2E2&hl...

3 Replies

Avatar

Former Community Member

You have to add the subform (it will be at the bottom) then you need to move it to the desired location. I created a sample that shows this. Add a few rows then hit the Add Special Item button.

Paul

Avatar

Level 1

Paul,

Thanks for the reply. Is there something wrong with the file? I can not get it to open. It says "invalidated enumerated value: Index change the fault occured on line 21" when I try to open the file.

Thanks!

-Brian

Avatar

Former Community Member

Opens fine for me ......I see that you are on Designer 7 that might be the issue. Here is the code that I used to add then move the subform:

// Invoke the Instance Manager to add one instance of the detail subform.

details._detail.addInstance(1);

//Get the total number of detail subforms
count = details._detail.count;

//Ask the user where they want to put the subform
loc = app.response("Please enter the row number where you want the new row to appear:");

//Move the subform to the desired location (note that instances are 0 based and the count is 1 based)

details._detail.moveInstance(count - 1, loc - 1);

//Invoke the recalculate method to include the field values from the added row in calculations.
xfa.form.recalculate(1);

Hope that helps

Paul