Showing posts with label InfoPath. Show all posts
Showing posts with label InfoPath. Show all posts

Thursday, February 04, 2010

How to clear infopath repeating table data

public void ClearInfoPathTableData(string TABLE_PATH, List TableRowTitles)
{
int TempCount;

//Delete from last.
while (true)
{
TempCount = Root.Select(TABLE_PATH, NamespaceManager).Count;//Get the n.of rows to clear
if (TempCount == 1)
{
for (int count = 0; count < TableRowTitles.Count; count++)
{
XPathNavigator node = Root.SelectSingleNode(TABLE_PATH + "[1]/" + TableRowTitles[count], NamespaceManager);

if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
{
node.DeleteSelf();
}
node.SetValue("");
}
}
break;
}
Root.SelectSingleNode(TABLE_PATH + "[" + TempCount + "]", NamespaceManager).DeleteSelf();
TempCount = Root.Select(TABLE_PATH, NamespaceManager).Count;
}
}

Getting the Field Values of Infopath Form stored in Sharepoint Form Library

//Get the Site
SPSite site= new SPSite(SITE_URL);
SPWeb Web = site.OpenWeb();
SPFile File = Web.GetFile(InfoPathDocUrl);

//Load the file into XML Document
XmlDocument Document = new XmlDocument();
Document.Load(File.OpenBinaryStream());

//Get the Root node and NamespaceManager of the Infopath form
XmlElement root = Document.DocumentElement;
XmlNamespaceManager NamespaceManager = InitNamespaceManager(Document);

//Get the Field values
string Field1Value= root.SelectSingleNode(Field1XPath, NamespaceManager).InnerText;
string Field2Value= root.SelectSingleNode(Field2XPath, NamespaceManager).InnerText;

Monday, February 01, 2010

How to update Infopath form fields Programatically?

public static void UpdateInfopathFormData(SPFile File, string NodeXPath, string UpdateValue,string NameSpace)
{
XmlDocument Document = new XmlDocument();
Document.Load(File.OpenBinaryStream()); // Get the FDRY document file into an XML Document

XPathNavigator root = Document.CreateNavigator();
XmlNamespaceManager nsm = new XmlNamespaceManager(Document.NameTable);
nsm.AddNamespace("my", NameSpace);//Get the NameSpace from infopath form(Open Infopath form in design mode. Click on datasource from design tasks.Click on any field. Go to properties. Go to Detalis Tab. Copy the "Namespace" value).

SetValueSpecial(root, NodeXPath, UpdateValue, nsm);
Byte[] data = Encoding.UTF8.GetBytes(Document.OuterXml);
File.SaveBinary(data);
}

public static void SetValueSpecial(XPathNavigator Root, string path, string value, XmlNamespaceManager NamespaceManager)
{

XPathNavigator node = Root.SelectSingleNode(path, NamespaceManager);

if (node.MoveToAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance"))
{
node.DeleteSelf();
}
node.SetValue(value);
}

How to display hand icon on mouse over of Infopath Button?

1. Open the Infopath Form in Design mode.
2. Click on "Save as Source Files..." from File menu.
3. Go to the folder where Source files are stored.
4. Open the xsl file for which you want to display hand icon on buttons.(Note that it ill create an xsl file for each view of the infopath form).

5. Search for the button with "type="button" in search criteria
6. For that button style add "CURSOR: pointer;".
Ex:
input class="langFont" title="" style="BORDER-RIGHT: #cbd8eb 1pt solid; BORDER-TOP: #000000 1pt; FONT-WEIGHT: bold; FONT-SIZE: xx-small; BORDER-LEFT: #cbd8eb 1pt solid; WIDTH: 82px; COLOR: #ffffff; BORDER-BOTTOM: #000000 1pt; HEIGHT: 17px; BACKGROUND-COLOR: #00003c; CURSOR: pointer;" type="button" size="1" value="Close" xd:CtrlId="BtnClose" xd:xctname="Button"

7. Save the file.
8. Next publish the manifest file(manifest.xsf) to the Sharepoint library.
9. Now if you open the infopath file and mouse over the button, it will display hand icon instead of pointer.

Wednesday, November 04, 2009

How to dislay Hand Icon for Buttons on mouse over in Infopath Forms

To display the Hand icon instead of pointer on mouse over of Button in Infopath Form, follow the steps below:

1) Open the Infopath form(InfopathForm.xsn) in design mode.

2) Save the form as Source Files ( Go to File menu, click on "Save As Source Files...)

3) Go to the saved Source Files location and open the xsl file(notice that it will create an xsl file for each view in the Infopath form) in an editor.

4) Search for "type="button"" and for that button style add "cursor:pointer". Save the file

5) Open "manifest.xsf" file in design mode from the same location.

6) Publish the manifest.xsf file.

7) Upload the file to Sharepoint Site.

8) Open the form in Sharepoint site and check if the buhand icon is displayed on button mouse over.

Wednesday, June 10, 2009

Error in accessing Web Service in VSTA code of Infopath Form

When I am trying to access the web serice method in the VSTA code of Infopath form, I was getting the following error message:

The error message is “There is an error in XML document (1, 302)."

The stack trace is “ at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)

at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)

at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

at EmpSepChkLst.AD_SEARCH.NDAWebService.SerachUserInDomain(String UserName)

at EmpSepChkLst.CommonFunctions.GetUserInfo(String CurrentUserId)”.


The solution for this is:

You need to publish the infopath form with full permission( Tools -> Form Options -> Security and Trust -> Select Full trust). I was publishing with "Domain" permissions and it was throwing the error while opening the infopath form from Sharepoint Document Library.

Error while submitting Infopath form to a SharePoint Document Library

I was getting the following error when submitting the Info path Form to a SharePoint Document library:
"An exception of type 'System.Net.WebException' occurred in Microsoft.Office.InfoPath.Server.dll but was not handled in user code

Additional information: A value in the form may be used to specify the file name. If you know the value in the form that specifies the file name, revise it and try again. Otherwise, contact the author of the form template."


You need to make the changes in the share point submit data connection. The following steps will walk you through

1. Open form in Design Form
2. Go to Tools in menu bar
3. Select data connection
4. Select the Dta connection name that you had used to submit the form to Share Point
5. Click on 'Modify' button
6. Check 'Allow overwrites if file exists' check box
7. click on 'Next' button
8. Click on 'Finish' button
9. Click on 'Close' button
10. Save the form and republish the form to Your form Library