Jscript for the New Record button

E

Eric

Can anyone provide what the code is for the New Record button?

When I press a button, I need to create a new record in a different view.

Thanks,
Eric
 
S

Scott L. Heim [MSFT]

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.
 

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