problems referencing from another view - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » problems referencing from another view problems referencing from another view Last post 08-03-2008 12:56 PM by canadianjameson. 13 replies. Page 1 of 1 (14 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 07-30-2008 11:32 AM canadianjameson Joined on 07-30-2008 Posts 9 problems referencing from another view Reply Contact Hi, I'm abysmally new to Infopath and I'm helping a friend get something up and running but we have hit a snag. We have a bunch of different views, and when a form is submitted we want to have the changes saved in a log table. Now the button code that we are using is as followsfunction CTRL134_5::OnClick(eventObj) {// Write your code here XDocument.View.ExecuteAction("xCollection::insert", "group7_6"); } however the problem is that when this button is placed on a view other than the "log view", it does not add the new data to the log table.We get this error when the button is placed on another view:The following error occurred:The specified varXmlToEdit value for the View.ExecuteAction call is not valid.File:script.jsLine:219 There's a good chance that I haven't explained this properly, but I will be happy to provide extra info if it's needed Cheers, and thanks again p.s: he seems to think it's a problem of the rules being executed before the code, at which point the form is being closed before the data is sent to the log. is this possible? If so, what do we do? 07-30-2008 11:44 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Hello, and welcome! Notice that you are inserting a particular group: "group7_6". On a different view, the control will have a different name. Right click the log table in the view you've copied the button to, and check the name of your group. You probably also need to check the name of your button and click the Edit Code button to create a new event handler for the button, then copy your code in. Let me know if you need more information, okay? Hilary Stoupa 07-30-2008 11:55 AM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Hi, Thanks for you response :) I checked the button ID's and they were the same, but even when I changed them so that they were unique (and also changed the code to reflect the two ID's, I got the same error message What could be causing this? 07-30-2008 12:44 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact From the MSDN page for View.ExecuteAction, the error is probably from: The varXmlToEdit parameter does not match an editing component that is defined in the view. (For further reference, here is a link to the page.) I did a quick sample form with two views and a two tables connected to the same group in my data source (thus, they both had the same id) and calling the View.ExecuteAction on that group id added rows to the tables in both views. I also added another table connected to a different data source, and modified the script to add rows to that table, and had no problems. I just re-read your post -- are you trying to add data? Because the code you have will simply add a new blank row to a repeating group.... Hilary Stoupa 07-31-2008 01:33 PM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Hi, sorry for the delay.we are just adding a row because the default values take care of the rest. If its simpler we could add a row and data via code for troubleshooting purposes.the "group7_6" is the varxmltoedit parameter that we are trying to use (i don't know if that made any sense), but it seems like it can't seem to find it if its on a different view. Basically the objective here is to copy form field data (which is entered onto a form by a user) into a log file as part of the action taken when the form is saved. the problem seems to be that when Form A looks for "group7_6" on Form B, it returns the error.from your message above: The varXmlToEdit parameter does not match an editing component that is defined in the view, it would seem that looking across views for variables generates the error we're getting -- how did you manage to do it? Thanks again for all of your help :) 07-31-2008 02:12 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact I think I get what you are saying now! View1 has the button, View2 has the table. You want to click the button in View1 and add a row to the table in View2--but you are right, you can't because the table doesn't exist in View1. However, you can add another table in View1 (connected to the same group, of course) and then use conditional formatting to hide it. Your condition could be The expression and then type "true" in the next field, and select Hide this control. Be sure in your repeating table properties, you deselect Header and the Show insert button and hint text box. That way your control is on your view, you can use your script on your button, and it will add rows to the table on the other view.... Let me know if I'm still not quite understanding what you are trying to do, okay? Hilary Stoupa 08-01-2008 09:45 AM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Hi, That seems to have done the trick :) I hope you don't mind but I have two other small questions: we're try to do something like this: http://blogs.msdn.com/infopath/archive/2005/06/17/430347.aspx however it doesn't generate an error but doesn't seem to be working either; any thoughts? The comments seem to be negative as well so maybe there is a glitch in the code :( Secondly, I am looking to code the submit button using jscript. The button is doing 2 things1 - adding to the log file via code2 - submitting form (but the rules do a quick check for something and either submit the form using one connection or another), and then it closes the form 1 is taken care of via code, I just need code for the if statement, whatever the syntax is for submitting the form, and the code to close it. Is it the same sort of code used to program websites in JavaScript? or is it some sort of special severside version? Thanks again, and sorry for my lack of expertise :) 08-01-2008 11:05 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact No worries on the lack of expertise -- we've all felt that way with IP! So you want to run code before rules? It does work ... I just did it recently (using the same blog post for reference. You are using javascript? Your function does need to return true so that your rules will run afterward. What is happening that makes you say it is not working? Is your code not executing? The rules following your code aren't executing? Is your form browser compatible? I don't believe you can use this in browser forms. Here is an article on MSDN about submitting -- towards the end is a code sample that may help you. Hilary Stoupa 08-02-2008 01:06 PM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Hi, Well, another day another progression and a new error is born :) We got it working but have now run into a weird error: "Infopath cannot insert the section or row because of an error" and the details show: "Attempt to modify a read-only node." Now the table that we're writting to isn't read only, and this function works if we call it through the code like so:function CTRL134_5::OnClick(eventObj) { // Write your code here XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); } but when we try to call it via a rule, like explained in the blog, it generates the error above. the code for the rule call is:function Test() { XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); return true; } and the rule we're using is:the expression: xdExtension:Test() Any ideas? It seems weird that calling the same function would work via one method an not the other. maybe it has something to do with the xdExtension method and the type of function we're calling? I don't know Thanks for your help, and please let me know if I'm being a bother :( 08-02-2008 02:42 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact No bother at all -- but I confess, I'm stumped. I tried it in a sample and had the exact same result. I even changed the code to clone and append the node, just in case it was the xCollection::insert. I've used the code before rules thing before, but only to add an event to an Outlook Calendar -- so not modifying the form at all. I saw this post where it looked like someone else was having a similar trouble with the same method.... You may need to do whatever you were handling in rules in the form's code.... which is kind of ugly. Hilary Stoupa 08-02-2008 04:28 PM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact success! ish. lol okay we created a work around whereby we have a hidden text box and we coded the submit button to change the value of the text box, and used the OnAfterChange event to fire the code, like such function msoxd_my_field133::OnAfterChange(eventObj) { // Write code here to restore the global state. XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); } but the problem is that this seems to be calling the above function twice and inserting two rows for every one click :( is there any way around this? there has to be 08-03-2008 11:02 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact Here is where things start to get wacky. The onAfterChange event runs twice. Yes, that’s right. It runs the first time to delete the previous value of the node, then a second time to insert the new value. There is a way to make sure you only hit your code once, however – add an if statement with the condition eventObj.Operation == “Insert” and set your code in that. So: function msoxd_my_field133::OnAfterChange(eventObj) { // Write code here to restore the global state. if (eventObj.Operation == “Insert”) { XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); }} Nice work around for your rules/code problem, by the way! Hilary Stoupa 08-03-2008 12:23 PM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact That's PERFECT! Thank you so much :)! I can't tell you how much time this has saved me :) Hopefully I can muddle through from here on in, but with my luck I just might post again :) Cheers, and thanks again :) Jay p.s: if you have any experience with K2.net, would you mind terribly having a quick look here: http://www.infopathdev.com/forums/p/8696/31149.aspx#31149 ? *sheepish smile* 08-03-2008 12:56 PM In reply to canadianjameson Joined on 07-30-2008 Posts 9 Re: problems referencing from another view Mark as Not AnswerMark as Answer... Reply Contact hehe, I guess I had a little more confidence in my muddling skills than I should have :) -- i posted like 5 mins ago, lol I have a table, and one of it's fields is a dropdown menu with two options: approved and rejected. I need to have the table rows re-order themselves based on this selection. Essentially I need all the rows with the field set to 'approved' to display above all the fields set to 'rejected'. is this hard to do? and secondly, I'm looking to employ conditional formatting based on what view the user is in but i can't seem to find out how to reference the current view :( any ideas? I mean i could just have a hidden field in ever view containing that views name and the use conditional formatting based on that condition, but there HAS to be a built in method like 'this.view()' or something similar... i just cant find it :( edit: I found this and I think it's what i need, thanks to you :) http://www.infopathdev.com/forums/t/7915.aspx Page 1 of 1 (14 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Hi,
I'm abysmally new to Infopath and I'm helping a friend get something up and running but we have hit a snag. We have a bunch of different views, and when a form is submitted we want to have the changes saved in a log table. Now the button code that we are using is as follows
XDocument.View.ExecuteAction("xCollection::insert", "group7_6"); }
however the problem is that when this button is placed on a view other than the "log view", it does not add the new data to the log table.
We get this error when the button is placed on another view:
The following error occurred:The specified varXmlToEdit value for the View.ExecuteAction call is not valid.File:script.jsLine:219
There's a good chance that I haven't explained this properly, but I will be happy to provide extra info if it's needed
Cheers, and thanks again
p.s: he seems to think it's a problem of the rules being executed before the code, at which point the form is being closed before the data is sent to the log. is this possible? If so, what do we do?
Hello, and welcome!
Notice that you are inserting a particular group: "group7_6". On a different view, the control will have a different name. Right click the log table in the view you've copied the button to, and check the name of your group. You probably also need to check the name of your button and click the Edit Code button to create a new event handler for the button, then copy your code in.
Let me know if you need more information, okay?
Thanks for you response :) I checked the button ID's and they were the same, but even when I changed them so that they were unique (and also changed the code to reflect the two ID's, I got the same error message
What could be causing this?
From the MSDN page for View.ExecuteAction, the error is probably from: The varXmlToEdit parameter does not match an editing component that is defined in the view. (For further reference, here is a link to the page.)
I did a quick sample form with two views and a two tables connected to the same group in my data source (thus, they both had the same id) and calling the View.ExecuteAction on that group id added rows to the tables in both views. I also added another table connected to a different data source, and modified the script to add rows to that table, and had no problems.
I just re-read your post -- are you trying to add data? Because the code you have will simply add a new blank row to a repeating group....
Hi, sorry for the delay.
we are just adding a row because the default values take care of the rest. If its simpler we could add a row and data via code for troubleshooting purposes.the "group7_6" is the varxmltoedit parameter that we are trying to use (i don't know if that made any sense), but it seems like it can't seem to find it if its on a different view. Basically the objective here is to copy form field data (which is entered onto a form by a user) into a log file as part of the action taken when the form is saved. the problem seems to be that when Form A looks for "group7_6" on Form B, it returns the error.
from your message above: The varXmlToEdit parameter does not match an editing component that is defined in the view, it would seem that looking across views for variables generates the error we're getting -- how did you manage to do it?
Thanks again for all of your help :)
I think I get what you are saying now! View1 has the button, View2 has the table. You want to click the button in View1 and add a row to the table in View2--but you are right, you can't because the table doesn't exist in View1. However, you can add another table in View1 (connected to the same group, of course) and then use conditional formatting to hide it. Your condition could be The expression and then type "true" in the next field, and select Hide this control. Be sure in your repeating table properties, you deselect Header and the Show insert button and hint text box. That way your control is on your view, you can use your script on your button, and it will add rows to the table on the other view....
Let me know if I'm still not quite understanding what you are trying to do, okay?
That seems to have done the trick :) I hope you don't mind but I have two other small questions: we're try to do something like this: http://blogs.msdn.com/infopath/archive/2005/06/17/430347.aspx however it doesn't generate an error but doesn't seem to be working either; any thoughts? The comments seem to be negative as well so maybe there is a glitch in the code :(
Secondly, I am looking to code the submit button using jscript.
The button is doing 2 things1 - adding to the log file via code2 - submitting form (but the rules do a quick check for something and either submit the form using one connection or another), and then it closes the form
1 is taken care of via code, I just need code for the if statement, whatever the syntax is for submitting the form, and the code to close it. Is it the same sort of code used to program websites in JavaScript? or is it some sort of special severside version?
Thanks again, and sorry for my lack of expertise :)
No worries on the lack of expertise -- we've all felt that way with IP!
So you want to run code before rules? It does work ... I just did it recently (using the same blog post for reference. You are using javascript? Your function does need to return true so that your rules will run afterward. What is happening that makes you say it is not working? Is your code not executing? The rules following your code aren't executing? Is your form browser compatible? I don't believe you can use this in browser forms.
Here is an article on MSDN about submitting -- towards the end is a code sample that may help you.
Well, another day another progression and a new error is born :)
We got it working but have now run into a weird error:
"Infopath cannot insert the section or row because of an error" and the details show: "Attempt to modify a read-only node."
Now the table that we're writting to isn't read only, and this function works if we call it through the code like so:function CTRL134_5::OnClick(eventObj) { // Write your code here XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); }
but when we try to call it via a rule, like explained in the blog, it generates the error above. the code for the rule call is:function Test() { XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); return true; } and the rule we're using is:the expression: xdExtension:Test()
Any ideas? It seems weird that calling the same function would work via one method an not the other. maybe it has something to do with the xdExtension method and the type of function we're calling? I don't know
Thanks for your help, and please let me know if I'm being a bother :(
No bother at all -- but I confess, I'm stumped. I tried it in a sample and had the exact same result. I even changed the code to clone and append the node, just in case it was the xCollection::insert. I've used the code before rules thing before, but only to add an event to an Outlook Calendar -- so not modifying the form at all. I saw this post where it looked like someone else was having a similar trouble with the same method....
You may need to do whatever you were handling in rules in the form's code.... which is kind of ugly.
success! ish. lol
okay we created a work around whereby we have a hidden text box and we coded the submit button to change the value of the text box, and used the OnAfterChange event to fire the code, like such
function msoxd_my_field133::OnAfterChange(eventObj) { // Write code here to restore the global state. XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); }
but the problem is that this seems to be calling the above function twice and inserting two rows for every one click :(
is there any way around this? there has to be
Here is where things start to get wacky. The onAfterChange event runs twice. Yes, that’s right. It runs the first time to delete the previous value of the node, then a second time to insert the new value. There is a way to make sure you only hit your code once, however – add an if statement with the condition eventObj.Operation == “Insert” and set your code in that. So:
function msoxd_my_field133::OnAfterChange(eventObj) { // Write code here to restore the global state. if (eventObj.Operation == “Insert”) { XDocument.View.ExecuteAction("xCollection::insert", "Log_Group_189"); }}
Nice work around for your rules/code problem, by the way!
That's PERFECT!
Thank you so much :)! I can't tell you how much time this has saved me :)
Hopefully I can muddle through from here on in, but with my luck I just might post again :)
Cheers, and thanks again :)
Jay
p.s: if you have any experience with K2.net, would you mind terribly having a quick look here: http://www.infopathdev.com/forums/p/8696/31149.aspx#31149 ? *sheepish smile*
hehe, I guess I had a little more confidence in my muddling skills than I should have :) -- i posted like 5 mins ago, lol
I have a table, and one of it's fields is a dropdown menu with two options: approved and rejected. I need to have the table rows re-order themselves based on this selection. Essentially I need all the rows with the field set to 'approved' to display above all the fields set to 'rejected'. is this hard to do?
and secondly, I'm looking to employ conditional formatting based on what view the user is in but i can't seem to find out how to reference the current view :( any ideas? I mean i could just have a hidden field in ever view containing that views name and the use conditional formatting based on that condition, but there HAS to be a built in method like 'this.view()' or something similar... i just cant find it :(
edit: I found this and I think it's what i need, thanks to you :) http://www.infopathdev.com/forums/t/7915.aspx