populate an InfoPath form by specifying a saved instance of it - InfoPath Dev Sign in | Join | Help in General 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 » General » populate an InfoPath form by specifying a saved instance of it Use our Google Custom Search for best site search results. populate an InfoPath form by specifying a saved instance of it Last post 02-17-2010 05:59 AM by princevis. 10 replies. Page 1 of 1 (11 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 02-16-2010 04:12 AM damith Joined on 02-16-2010 Posts 6 populate an InfoPath form by specifying a saved instance of it Reply Contact I'm new to InfoPath development and need help from experts in this forum, currently i'm developing application using InfoPath 2003 and visual studio 2005, the requirement is to populate an InfoPath form by specifying a saved instance of it without opening a new instance. can anybody guide me to do this work? thanks Damith Sameera Weerasinghe Filed under: Infopath 2003, vs 2005, infopath, c# 02-16-2010 05:01 AM In reply to princevis Joined on 08-17-2009 Delhi Posts 129 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Hi Damith could you be more specific in terms of your requirement, i mean if you want to open saved instance of an infopath form, you already have a save option in infopath forms,using which the form gets saved with a unique id to a form library and you can open or edit it later.If there is something else that you want,please explain.. Vishal SrivastavaSenior Software EngineerSDG Software Pvt Ltd 02-16-2010 05:50 AM In reply to damith Joined on 02-16-2010 Posts 6 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact thanks Vishal for quick response, i have InfoPath form with set of input text boxes and drop downs, in same form there is a button called save, which used to save InfoPath form as XML file. in top of that form user can select previously saved InfoPath XML files in a drop down and load the XML parameters to the form by clicking on load button. i have problems with loading previous XML files and bind it to InfoPath form, what is the correct way to load XML back to InfoPath Form? changing form DOM XML or any other way? please help me. thanks Damith Sameera Weerasinghe 02-16-2010 08:59 PM In reply to princevis Joined on 08-17-2009 Delhi Posts 129 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Dear Damith, do u want to load xml files as attachment to inopath form.. Vishal SrivastavaSenior Software EngineerSDG Software Pvt Ltd 02-16-2010 11:09 PM In reply to damith Joined on 02-16-2010 Posts 6 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Dear Vishal, InfoPath form can save as XML; I need to load data from one of those xml files back to InfoPath form using c# code Thanks, Damith Sameera Weerasinghe 02-16-2010 11:36 PM In reply to princevis Joined on 08-17-2009 Delhi Posts 129 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Dear Dmith, You can make form library as secondary data connection and then u can use secondary data connection to populate the infopath form, by conditional formatting you can make a check if the xml value in dropdown exists,and if it does populate the form with data in xml form.Let me know if your functionality is achieved.. Vishal SrivastavaSenior Software EngineerSDG Software Pvt Ltd 02-17-2010 04:24 AM In reply to damith Joined on 02-16-2010 Posts 6 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact I'm able to replace DOM of infopath form using XML file as below, this is working fine in debug mode, however when open the infopath file it prompt error message. [InfoPathEventHandler(MatchPath="CTRL2_5", EventType=InfoPathEventType.OnClick)]public void CTRL2_5_OnClick(DocActionEvent e) { // Create a System.Xml XmlDocument and load an XML file.XmlDocument doc = new XmlDocument(); doc.Load("C:\\Form1.xml"); // Create an MSXML DOM object.IXMLDOMDocument2 newDoc = (IXMLDOMDocument2)thisXDocument.CreateDOM(); // Load the DOM with the XML from the System.XML object. newDoc.loadXML(doc.DocumentElement.OuterXml);newDoc.setProperty("SelectionNamespaces", "xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-02-16T10:55:20\""); IXMLDOMNode newNode = newDoc.selectSingleNode("/my:myFields");IXMLDOMNode rootNode = thisXDocument.DOM.selectSingleNode("/my:myFields"); //replace it with the new root node rootNode.parentNode.replaceChild(newNode, rootNode); } This is the error message prompt when click on the button: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) at System.Threading.CompressedStack.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) at System.Xml.XmlTextReaderImpl.OpenUrl() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(String filename) at KithPrj2.KithPrj2.CTRL2_5_OnClick(DocActionEvent e) at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent) Why this is only working in debug mode? how to avoid this error? Damith Sameera Weerasinghe 02-17-2010 04:27 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,594 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact The template's trust level must be set to full trust in order to access files on the local filesystem. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 02-17-2010 04:27 AM In reply to princevis Joined on 08-17-2009 Delhi Posts 129 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Dear Damith please check if your infopath form is set to full trust mode. Vishal SrivastavaSenior Software EngineerSDG Software Pvt Ltd 02-17-2010 05:45 AM In reply to damith Joined on 02-16-2010 Posts 6 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact Thanks Jimmy and Vishal, I'm able to fix the issue, by setting full trust and signing the form. Thanks again for helping me to solve these issues by giving correct guidance Damith Sameera Weerasinghe 02-17-2010 05:59 AM In reply to princevis Joined on 08-17-2009 Delhi Posts 129 Re: populate an InfoPath form by specifying a saved instance of it Mark as Not AnswerMark as Answer... Reply Contact You are most welcome Damith. It's an honour to be of some help.. Vishal SrivastavaSenior Software EngineerSDG Software Pvt Ltd Page 1 of 1 (11 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Use our Google Custom Search for best site search results.
Hi Damith
could you be more specific in terms of your requirement, i mean if you want to open saved instance of an infopath form, you already have a save option in infopath forms,using which the form gets saved with a unique id to a form library and you can open or edit it later.If there is something else that you want,please explain..
Dear Damith,
do u want to load xml files as attachment to inopath form..
Dear Vishal,
InfoPath form can save as XML; I need to load data from one of those xml files back to InfoPath form using c# code
Thanks,
Dear Dmith,
You can make form library as secondary data connection and then u can use secondary data connection to populate the infopath form, by conditional formatting you can make a check if the xml value in dropdown exists,and if it does populate the form with data in xml form.Let me know if your functionality is achieved..
[
{
// Create a System.Xml XmlDocument and load an XML file.
doc.Load(
newDoc.loadXML(doc.DocumentElement.OuterXml);
rootNode.parentNode.replaceChild(newNode, rootNode);
}
This is the error message prompt when click on the button:
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) at System.Threading.CompressedStack.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) at System.Xml.XmlTextReaderImpl.OpenUrl() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(String filename) at KithPrj2.KithPrj2.CTRL2_5_OnClick(DocActionEvent e) at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Why this is only working in debug mode? how to avoid this error?
Dear Damith
please check if your infopath form is set to full trust mode.
Thanks Jimmy and Vishal,
I'm able to fix the issue, by setting full trust and signing the form.
Thanks again for helping me to solve these issues by giving correct guidance
You are most welcome Damith.
It's an honour to be of some help..