Showing posts with label Infopath. Show all posts
Showing posts with label Infopath. Show all posts

Sunday, December 6, 2009

How to read & write value from Infopath Datasource throught C#

Hi,

In a requirement, we need to display views based on the current user who updates the infopath form. So I thought let me write the logic to read and store values in Info path Data source from code behind. Following Code useful.

Read:
XPathNavigator nav = MainDataSource.CreateNavigator();
string fieldValue = nav.SelectSingleNode("//my:Myfield1", NamespaceManager).Value;

Write:
XPathNavigator nav = MainDataSource.CreateNavigator();
nav.SelectSingleNode("//my:Myfield1", NamespaceManager).SetValue("NewValue");

essential Namespace is Microsoft.Office.InfoPath;

Hope it helps...

Best Regards
Fauzi ~4Z

Monday, November 30, 2009

Publish Infopath form with CodeBehind

Hey,

When I publish a normal infopath form without code behind, I was able to publish them from Info path editor it self and on click of 'New' in forms library, i was able to view the form in the Browser. But when i tried to publish with Codebehind and Click 'New' the form only opened in a New editor!

When i googled for the same, came to know that when we add code behind logic (say with C#) first we need to publish and later we need to approve the info path form through Sharepoint Administration.

There are four steps to be implemented:

  • Publish the Template to the File System
  • Upload the Template to Central Administration Form Templates Library
  • Activate the Form Template in your Site Collection
  • Associate the Form Template with the Form Library
It is clearly given in the following Link: Click
Its very helpful...


Thanks
Fauzi