Add a line to repeating table if formhas several views

A

Andrei

Hi, I had started to create new form with two views (View1 and view2).
View1 includes the several fields and repeating table. Users fill out the
view1 and submit data to database with using web service.
View2 is using for reading information from database (web service) and
present it for user. Plus, if I want to update information in a record that
presented by view2 I use a button with a code. Code copy information from the
fields in view2 to fields in view1.

The problem is with adding new line to repeating table in view1 from view2.
The error:
"The following call in the form's code failed:View.ExecuteAction Unspecified
error.

This is a piece of my code:

XDocument.View.SwitchView("view1);
XDocument.View.ExecuteAction("xCollection::insert", "Item_8");

If I add a button to view1 with the same code I can add a line to repeating
table.

Dose anybody know how to overcome this problem?

Thank you,
Andrei
 
G

Greg Collins [InfoPath MVP]

It is a timing issue. The view switch hasn't "really" occured by the time your insert gets called. The view has not been drawn yet -- so it doesn't really exist.

Your best bet is to use code to manaully insert the nodes via ..appendChild()

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Hi, I had started to create new form with two views (View1 and view2).
View1 includes the several fields and repeating table. Users fill out the
view1 and submit data to database with using web service.
View2 is using for reading information from database (web service) and
present it for user. Plus, if I want to update information in a record that
presented by view2 I use a button with a code. Code copy information from the
fields in view2 to fields in view1.

The problem is with adding new line to repeating table in view1 from view2.
The error:
"The following call in the form's code failed:View.ExecuteAction Unspecified
error.

This is a piece of my code:

XDocument.View.SwitchView("view1);
XDocument.View.ExecuteAction("xCollection::insert", "Item_8");

If I add a button to view1 with the same code I can add a line to repeating
table.

Dose anybody know how to overcome this problem?

Thank you,
Andrei
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top