Hi Eric,
Here is some sample JScript code that will first switch to the other view
(in this sample that view is named: View 2) and then execute the same basic
code as if you pressed the New Record button. Keep in mind, this does not
do any "validating" to see if the user wanted to save the existing data
before creating the new record:
//Switch to the other view
XDocument.View.SwitchView("View 2");
//This code provides the same functionality as using the "New Record"
button
var domTemplate = new ActiveXObject("MSXML2.DOMDocument.5.0");
domTemplate.async = false;
domTemplate.validateOnParse = false;
domTemplate.load("template.xml");
var existingDataFields = XDocument.DOM.selectSingleNode("//my:myFields");
domTemplate.setProperty("SelectionNamespaces",
'xmlns:my="
http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-09-0
1T17:54:25"');
var newDataFields = domTemplate.selectSingleNode("//my:myFields");
existingDataFields.parentNode.replaceChild(newDataFields.cloneNode(true),
existingDataFields);
existingDataFields = null;
domTemplate = null;
newDataFields = null;
I hope this helps!
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.