Expand my Community achievements bar.

SOLVED

AddInstance not working-please Help

Avatar

Level 1

I have been working on a form in Livecycle and have hit a brick wall. I have tried everything I know. I have the subforms marked as flowed and the repeating box on the binding saved. Also have saved it in a dynamic form. What I need is a every subform to have a simple add button on for a row but on the bottom I need the add button to be able to copy the entire table. I have read every post I can find and still nothing.

https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0ByHqZuKg4V-OYzQ3NWUxNzEtYjMyYy00N...

Here is the link to the file.

Thank You,

Mark Rhoudes

mrhoudes@gmail.com

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

There were two things wrong with your form.

1. The code on the button to add an instance was incorrect. You want to replicate Table 3 so the syntax woudl be:

Table3.instanceManager.addInstance(1)

2. Doing that generates an error indicating that the subform Table3 has reached the max number of instances. So go into the binding tab for the Table 3 object and set the "Reapeat Table ofr Each Data Item" checkbox on and you will be good to go.

Note that you may need to re-arrange your form as you will find that once the first column breaks a page (i.e. bathroom) then you cannot go back a page and fill up the second column.

Hope that helps

Paul

View solution in original post

6 Replies

Avatar

Correct answer by
Former Community Member

There were two things wrong with your form.

1. The code on the button to add an instance was incorrect. You want to replicate Table 3 so the syntax woudl be:

Table3.instanceManager.addInstance(1)

2. Doing that generates an error indicating that the subform Table3 has reached the max number of instances. So go into the binding tab for the Table 3 object and set the "Reapeat Table ofr Each Data Item" checkbox on and you will be good to go.

Note that you may need to re-arrange your form as you will find that once the first column breaks a page (i.e. bathroom) then you cannot go back a page and fill up the second column.

Hope that helps

Paul

Avatar

Level 1

Now how do I get the total from the new boxes to add up together?

Avatar

Former Community Member

Are you looking to total up the table for a room or are you looking to total all tables into one final total from all rooms?

Paul

Avatar

Level 1

Both. I know how to get the overall total but dont know the code to make it add in the total for the new rooms?

Avatar

Former Community Member

This will involve some work ......you will need to name each of the rows in your table the same ...now you have it as row1, row2, row3 ......change it so that every row in the table has the same name (the product will add occurance numbers to make the fields unique). So if you named the rows Row then the result woudl be Row[0], Row[1], Row[2] ......note that you do not add the [x] the product will do it. Then you need to change the name of the Total field in each row to be the same I called mine Total. The occurances numbers will appear the same way as the rows.  Then create a formula to multiply quantity * Cost for each row. Now on your GrandTotal you can use a FormCalc calculation in the Calculate event of the Grand Total field. You can reference the Fields like this:

Sum(Page1.General.Table1.Row[

*].Total[*], Bathroom.Table3[*].Row[*].Total[*])

Note the use of the * in the occurance numbers ....this will reference every field with that structure so with a single statement we can add up all of the Totals from the General table and all Bathroom tables (note the * on the Table3 subform for when the user adds additional ones)....and as each row is completed the Grand Total will be calculated. You simply need to add an expression for each table you want to include in the GrandTotal calc ...sepearted by commas of course.

Lastly you should name all of your subforms ...it will make it easier when referencing objects in your Sum calculation.

I have modfied your previous sample to show you what I mean ( I did the General table and the Bathroom table only). See the attachment in this post.

Paul

Avatar

Former Community Member

Make sure that the settings in the Binding tab of the Object palette for the subform you are trying to duplicate are correct.  There is a checkbox labeled "Repeat Subform for Each Data Item".   Make sure that is checked.  It gets reset every time you make the page positioned.  If you have the Max checkbox checked, make sure there is a number > 1 in it.

The code to add an instance should look something like this in the click event of your add button:

MyForm.MySubform.instanceManager.addInstance(1); 

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----