If somebody like the post and its helpful in your work then, add comments.

Sunday, November 30, 2008

InfoPath Form Insertion and Delete in Repeting Table in Web Enabled Form

Inserting the data:

string myNamespace = NamespaceManager.LookupNamespace("my");
using (XmlWriter writer = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:NewCallByProduct", NamespaceManager).AppendChild())
{
writer.WriteStartElement("NewCallByProductSub", myNamespace);
writer.WriteElementString("ProductName", myNamespace, dr[0].ToString());
writer.WriteElementString("Count", myNamespace, count.ToString());
writer.WriteEndElement();
writer.Close();
}


Delete the data:

foreach (XPathNavigator XNav in MainXnav.Select("/my:myFields/my:NewCallByProduct/my:NewCallByProductSub", NamespaceManager))
{
XPathNavigator xNode = MainXnav.SelectSingleNode("/my:myFields/my:NewCallByProduct/my:NewCallByProductSub/my:ProductName", NamespaceManager);
string Xlocation = xNode.Value;
//string Xlocation = MainXnav.SelectSingleNode("/my:myFields/my:NewCallsByLocationGrp/my:NewCallsByLocationSubGroup/my:LocationName", NamespaceManager).Value;
if (Xlocation == "")
{
XNav.MoveToChild("NewCallByProductSub", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2008-03-03T17:40:51");
XNav.DeleteSelf();
}

}

Type of DataBases in SharePoint 2007

Configuration database: (Used by WSS and MOSS.) Contains SharePoint configuration settings, such as front-end and back-end servers, mail servers, and portal site names. The name for this database is SharePoint_Config.

Content database: (Used by WSS and MOSS.) Contains the actual data, stored in the portal site and the team sites. Default name prefix: WSS_Content.

Shared Services database: (Used by MOSS.) Used to store information about the Shared Service provided; its default name is SharedServices1_DB.

Shared Services Search database: (Used by MOSS.) Stores search index and related content in the database SharedServices1Search_DB.

Shared Services Content: (Used by MOSS.) Stores general information for the Shared Services Provider instances in the database SharedServices_Content.

Administrative Content: (Used by MOSS.) Stores content related to central administration in the database file SharePoint_AdminContent.

Add a trusted file location

About trusted file locations
In Microsoft Office SharePoint Server 2007, a trusted file location is a SharePoint document library, a UNC path, or an HTTP Web site that is configured as a trusted repository for workbooks that Excel Calculation Services can access. Excel Calculation Services opens workbooks that are stored in trusted file locations only.

If you are planning to use a new SharePoint document library as a trusted file location for Excel Services in Microsoft Office SharePoint Server 2007, create the new document library on a SharePoint site. To create the new document library, click the Site Actions menu, select Create, and then click Document Library. On the New page, type a name for the new document library and click Create.

Add a trusted file location
Use the following procedure to add a trusted file location.

Add a trusted file location
From Administrative Tools, open the SharePoint Central Administration Web application.

On the Central Administration home page, click Application Management.

On the Application Management page, in the Office SharePoint Server 2007 Shared Services section, click Create or Configure this Farm's Shared Services.

On the Manage this Farm's Shared Services page, click SharedServices1 (Default). This is the Shared Services Provider (SSP) that you will configure.

On the Shared Services home page, in the Excel Services Settings section, click Trusted file locations.

On the Excel Services Trusted File Locations page, click Add Trusted File Location.

In the Address section, type the location and name of the SharePoint Office SharePoint Server 2007 document library that you want to add as a trusted file location in Excel Services. If the document library is stored in the Windows SharePoint Services 3.0 content database, ensure that Windows SharePoint Services 3.0 is selected as the Location Type.

In the External Data section, select the type of data connections that you will allow workbooks in this trusted file location to contain and click OK.

In the External Data section, you can determine whether workbooks stored in trusted file locations and opened in Excel Calculation Services sessions can access an external data source. You can designate whether Allow External Data is set to None, Trusted data connection libraries only, or Trusted data connection libraries and embedded.

If you select either Trusted data connection libraries only or Trusted data connection libraries and embedded, the workbooks stored in the trusted file locations are allowed to access external data sources. External data connections can be accessed only when they are embedded in or linked from a workbook. Excel Calculation Services checks the list of trusted file locations before opening a workbook. If you select None, Excel Calculation Services will block any attempt to access an external data source. If you manage data connections for a large number of workbook authors, you might want to select Trusted data connection libraries only.

Auto Number in the Repeting table of InfoPath 2007

If you want to display a row number on a repeating table you can use an Expression Box with the XPath set to position(). This is great if all you want to do is show the row number. But if you actually want to store the sequential autonumber in a field, there's a different XPath you can use.

We will assume that you have the following structure representing your table row:

my:Row
my:Number
my:FieldX
my:FieldY
my:FieldZ

We will also assume that you want my:Number to be automatically populated with the row number, while staying continually updated as rows are inserted and removed.

Double-click the Number field in the repeating table.
On the Data tab of the Text Box Properties dialog box, ensure that the Update This Value When The Result Of The Formula Is Recalculated check box is selected.
Click the Insert Formula button to the right of the Default Value text box.
In the Insert Formula dialog box, type the following formula:

count(../preceding-sibling::my:Row) + 1



Click OK twice.
Now preview your form and try it out. Whether you insert or remove rows, each Number field has the correct row number stored in it.

How to loop through items in a repeating table in InfoPath 2007

XPathNavigator domNav = MainDataSource.CreateNavigator();
XPathNodeIterator rows = domNav.Select(
"/my:myFields/my:table/my:row", NamespaceManager);

while (rows.MoveNext())
{
string field1 = rows.Current.SelectSingleNode(
"my:field1", NamespaceManager).Value;
string field2 = rows.Current.SelectSingleNode(
"my:field2", NamespaceManager).Value;
string field3 = rows.Current.SelectSingleNode(
"my:field3", NamespaceManager).Value;
}

Regular Expression for InfoPath Pattern matching

Sr. No Type Regular Expression
1 Email \p{L}+@\p{L}+\.com
2 Number \d+
3 Strings
4 Date and Time
5 URI
6 Phone Numbers \(\d\d\d\) \d\d\d\-\d\d\d\d
7 Zip Code \d\d\d\d\d
8 Social Securtiy No \d\d\d\-\d\d\-\d\d\d\d
9

Get Subsite List

public void GetListItemS()
{
SPSite rootSite = new SPSite("http://mossvs2008");
SPWeb subSIte = rootSite.OpenWeb();
SPWebCollection SPWebCol = rootSite.AllWebs;
for (int i = 0; i < SPWebCol.Count; i++)
{
string titlestr = SPWebCol[i].Title;
Response.Write(titlestr);
if (titlestr == "VESample")
{
SPListCollection SPListCol = SPWebCol[i].Lists;
foreach (SPList SPSubList in SPListCol)
{
if (SPSubList.ToString() == "SampleList")
{
Response.Write(SPSubList.ToString());
}
}
}
}
}

Getting the XML of SharePoint 2007 list

1. Navigate to the SharePoint site that contains the list, for example:
http://contoso/sites/sales/Sales%20Contacts/Forms/AllItems.aspx
2. Go to “Modify settings and columns”
3. Copy the List={GUID} portion of the URL and paste this into a buffer like a Notepad window.
4. In Notepad, create the following URL (the blue portion us taken from the step 1 URL, and the red portion must be added.

http://contoso/sites/sales/_vti_bin/owssvr.dll?Cmd=Display&List={GUID}&XMLDATA=TRUE

Showing the message box from JavaScript in Web Enabled InfoPath form

Step 1: Using the NotifyHost Method to Send Notifications
You can use the NotifyHost method of the XmlForm class to send notifications to the hosting environment of a form template. Perform the following steps to add a Button control and its event handler to a form template, and call the NotifyHost method:
1.Open the InfoPath browser-compatible form template in design mode.
2.In the task pane, click Controls.
3.Add a Button control to the form template.
4.Right-click the Button control and select Button Properties.
5.On the Button Properties dialog box, click Edit Form Code to add a Clicked event handler to the form template’s business logic code.
6.Add the following code to the Button control’s Clicked event handler:
Code To add
NotifyHost("Message from InfoPath");

Step 2: Hooking Up the NotifyHost Event to an Event Handler
1. Open the FormServer.aspx from C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS
2. Add following code in FormServer.aspx after the page register tag

3. Publish the form