• About Ken
  • Ken’s CV

All About SharePoint

~ Liedong(Ken) Zheng, Independent SharePoint Consultant

All About SharePoint

Tag Archives: InfoPath

InfoPath Repeating Table Lookup control on SharePoint List

01 Wednesday Feb 2012

Posted by ken zheng in InfoPath

≈ Leave a comment

Tags

InfoPath, XPATH

It is common to get more values from the dropdown list. For example, when user select the product, more product details are retrieved.

image

image

image

image

 

image

Just type current() in the Formula

image

 

image

 

image

You need manually modify the XPATH,  “current()” function should fix this problem.

xdXDocument:GetDOM("Active Products (BCS)")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:SubSBU[../d:PRDNO = current()]

 

Reference:

http://rawatsumit.blogspot.com.au/2009/10/infopath-repeating-table-lookup-control.html

Advertisements

InfoPath Error: This session has exceeded the amount of allowable resources

23 Sunday Oct 2011

Posted by ken zheng in InfoPath, Sharepoint

≈ Leave a comment

Tags

InfoPath, SharePoiint 2010

Error:

Message : Name=Request

Message : Number of form actions, 209, has exceeded 200, the maximum allowable  value per request. This value is configurable and can be changed by the administrator.

 

image

Resolution:

Increase the form actions in configuring InfoPath services section as mentioned below:-

  • Go to Central Administration of the SharePoint server.
  • Click on General Application Settings
  • In the section "InfoPath Forms Services"–>select Configure InfoPath Forms Services.
  • In the Number of Actions per Post back, enter some max value around 250 or 300 depends on your project form requirement.
  • There are chances that the error may retain same even after we increase the number of actions per post back. The second thing we have to increase is the value of "Maximum size of form session state" to 8192. By default it is 4092, by increasing it to 8192 the error should go away.

InfoPath – User Roles in Browser-Enabled Forms Using AD Groups

04 Monday Jul 2011

Posted by ken zheng in InfoPath, Sharepoint

≈ 1 Comment

Tags

InfoPath, SharePoiint 2010

Clayton published a good article showing how to interact with SharePoint users. and John has summarised 10 tips for InfoPath design.

Power Shell Script to Check HREF ULR in InfoPath form

08 Wednesday Dec 2010

Posted by ken zheng in PowerShell

≈ Leave a comment

Tags

InfoPath, PowerShell

We have a system which contains thousands of InfoPath forms, the template files are in the SharePoint site. And some forms cannot be opened after some users editing because of the wrong InfoPath Cache. So I wrote the little scrip to loop all the forms and get HREF string to check if the url is valid.

Param($Path = "D:\Temp",[switch]$verbose)

Write-Host

$fc = new-object -com scripting.filesystemobject
$folder = $fc.getfolder($path)
$strFinder = "http.*xsn"
$logfile = "D:\Temp\NPILog.txt"

function ProcessFiles([string]$folderpath) {

Write-host " + Processing all Forms from: $folderpath"
$Forms = dir $folderpath "*.xml"

		Write-host "  + $($Forms.count) Forms found"
		Write-host " + Processing all $($Forms.count) Forms located at: $folderpath" -fore White

			foreach($Form in $Forms)
			{
				Write-Host "  + +	Processing Form: $($Form.Name)" -fore White
				Find-String  $strFinder $Form.FullName
			}	
	
}

function Find-String($find, $path)
{
    $url_values = New-Object System.Collections.ArrayList
	$i = 0
	echo "Finding string `"$find`" in file contents and file names of path: $path"
	ls $path | select-string $find -list |% { echo "Processing contents of $($_.Path)"; (get-content $_.Path) |% { [regex]::matches($_, $find) |%{$url_values.Add($_.value); $i++}} }
    echo $url_values[0]
	if(Check-URL $url_values[0])
	{
		Write-Host "$($path) href is fine"
	}
	else
	{
		Write-Host "$($path) href is wrong" -foregroundcolor red -backgroundcolor yellow
		Add-Content $logfile "$($path) href is wrong, checked at $(Get-Date)"

	}
}

function Check-URL($url)
{
	$urlIsValid = $false
	try
	{
		$request = [System.Net.WebRequest]::Create($url)
		$request.Credentials = [System.Net.CredentialCache]::DefaultCredentials;
		$request.Method = 'HEAD'
		$response = $request.GetResponse()
		$httpStatus = $response.StatusCode
		$urlIsValid = ($httpStatus -eq 'OK')
		$tryError = $null
		$response.Close()
	}
	catch [System.Exception] {
		$httpStatus = $null
		$tryError = $_.Exception
		$urlIsValid = $false;
	}
    
	return $urlIsValid
}

Write-Host "$($folder.ShortName) "
Write-Host "  + Total Folders: $($folder.SubFolders.Count)"
foreach ($i in $folder.SubFolders) {
	Write-Host "  + Folder Name: $($i.ShortName)"
	ProcessFiles($i.Path)
}

InfoPath Web Form Tips – Document ID + Name

02 Monday Aug 2010

Posted by ken zheng in Sharepoint

≈ Leave a comment

Tags

InfoPath

Most time you want to have a dropdown list  in your form to display ID & Name, but InfoPath form doesn’t provide your function to construct the display field. You can create a calculated field in your SharePoint list, but the problem is the form doesn’t recognized the “Calculated” column. or you can follow this blog.

But I found using SPD is much easier.

I use a variable to store the combined value and then set the value to the text field.

image

image

After uploading the document , the new field will look like

image

To hide the column from Editing, you need to modify it in the content type and set to hidden.

Follow here.

Inserting line breaks into text using Rules in InfoPath

14 Monday Dec 2009

Posted by ken zheng in Uncategorized

≈ Leave a comment

Tags

InfoPath, Line Breaks

If you are using solution from http://blogs.msdn.com/infopath/archive/2005/03/04/385577.aspx. You need to make sure that your textbox is formatted to be able to display paragraph breaks. To do this double-click on the text box control, go to the Display tab, and check the checkbox labeled “Allow paragraph breaks”.

After this, your code should work, but if it still doesn’t try using “\n” instead of the System.Environment.Newline.

There is another way to do that.
http://www.infopathdev.com/forums/t/2013.aspx

How to programmatically retrieve selected items in a Multiple-Selection list box in InfoPath

17 Tuesday Nov 2009

Posted by ken zheng in Sharepoint

≈ 1 Comment

Tags

InfoPath

Quite often you will need to get selected values from a Multiple-Selection list box to a field. I haven’t found a way to do in rules but the following code will solve the problem.

Suppose you have a Multiple-Selection List Box named myListBox on an InfoPath form and an after change event to fill a Text Box named myTextBox with the values or display names of the items that were selected in the Multiple-Selection List Box.

Retrieving the values of selected items
You could use the following C# code to retrieve the values that were selected:

        public void field13_Changed(object sender, XmlEventArgs e)
        {
            XPathNavigator root = MainDataSource.CreateNavigator();
            XPathNodeIterator iter = root.Select("//my:myListBox ",
              NamespaceManager);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            while (iter.MoveNext())
            {
                string value = iter.Current.Value;
                sb.Append(value);
                if (sb.Length > 0)
                {
                    sb.Append(";");
                }
            }

            root.SelectSingleNode("//my:myTextBox",
              NamespaceManager).SetValue(sb.ToString());
        }


Retrieving the display names of selected items

If you want to retrieve the Display Names of the items that were selected and you’ve bound the Multiple-Selection List Box to a repeating node either in the Main data source or a secondary data source, you’ll have to do a programmatic lookup to retrieve the Display Names.

You could use the following C# code to retrieve the display names of the items that were selected:

XPathNavigator root = MainDataSource.CreateNavigator();
XPathNodeIterator iter = root.Select("//my:myListBox",
  NamespaceManager);

System.Text.StringBuilder sb = new System.Text.StringBuilder();

while (iter.MoveNext())
{
  string value = iter.Current.Value;

  XPathNavigator secDS = DataSources["Fruits"].CreateNavigator();
  string displayName = secDS.SelectSingleNode(
    "/dfs:myFields/dfs:dataFields/d:Fruits[@ID = '"
    + value + "']/@Name", NamespaceManager).Value;

  sb.Append(displayName);
  sb.Append(";");
}

root.SelectSingleNode("//my:myTextBox",
 NamespaceManager).SetValue(sb.ToString());

where Fruits is a secondary data source, @ID the value of an item, and @Name the display name of an item.

Note: You cannot do a lookup for items if you’ve manually entered them into the list box.

More useful code you can find from http://www.bizsupportonline.net/blog/2009/03/programmatically-retrieve-selected-items-multiple-selection-list-box-infopath/

Get Count from SharePoint List for InfoPath

03 Friday Apr 2009

Posted by ken zheng in Sharepoint

≈ Leave a comment

Tags

InfoPath, Sharepoint

I always be asked to get a Numberic Id for new infopath form. Instead of writing code in Form, I created a Web Service which will go to the SharePoint List, grab the number and increment by 1, then update the list. By doing that, you can set rule in your Form Submit Button without code required.
Below is the code

[WebMethod]
        public int GetAndIncrementCount(string ListUrl, string CountName)
        {
            int count = 0;

            SPWeb oSPWeb = null;
            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (SPSite oSPSite = new SPSite(ListUrl))
                    {
                        oSPWeb = oSPSite.OpenWeb(ListUrl.Substring(ListUrl.IndexOf("/") + 1));
                    }
                });
                SPList oSPList = oSPWeb.GetList(ListUrl);

                if (oSPList != null)
                {
                    oSPWeb.AllowUnsafeUpdates = true;
                    SPListItemCollection items = oSPList.Items;
                    if (items.Count > 0)
                    {
                        SPListItem item = items[0];
                        count = int.Parse(item[CountName].ToString()) + 1;
                        item[CountName] = count;
                        item.Update();
                    }
                }
            }
            catch (Exception exception)
            {
                Log.WriteLogEvent(string.Format("An Error Occured In GetAndIncrementCount Method | Exception Message:{0} StackTrace: {1}", exception.Message, exception.StackTrace));
            }
            finally
            {
                oSPWeb.Dispose();
            }
            return count;
        }

Close InfoPath Forms Services form using Code

24 Tuesday Feb 2009

Posted by ken zheng in Sharepoint

≈ 3 Comments

Tags

InfoPath

I was working on a way to close an InfoPath form using C# or VB.NET from the form code-behind after the user submits the form. The steps below help in running some custom code to save the data and then close the form.

Here are the steps to close the Form

* Set the Submit Action[Tools->Submit Options] within InfoPath for the form to “Perform custom action using Code” . Click the Edit Code option to submit the form using code
* Set the After Submit option under Advanced to “Close the Form”

Click the Edit Code button next to the perform custom action to submit the data. Editing the code adds an handler for the Form Submit event and a FormEvents_Submit method is created in the code behind. Once the code completes the submission, set the CancelableArgs.Cancel property of the SubmitEventArgs to false.

Here is a sample FormEvents Submit method

In the SubmitConnection method, I retrieve the required data connection and call the execute method for submission

Dim fileSubmit as FileSubmitConnection = CType(Me.Connections(”SharePoint Save”),Microsoft.Office.InfoPath.FileSubmitConnection)

fileSubmit.Execute()

In the above sample, the data connection that I want to use for Submit is named “SharePoint Save”. I typecast it as a FileSubmitConnection.

I found this solution on one of the forum posts

http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2605818&SiteID=17

Infopath error: “The required version of the Microsoft .NET Framework is not installed on your computer or the InfoPath Primary Interop Assembly (PIA) is not registered”

06 Friday Feb 2009

Posted by ken zheng in Sharepoint

≈ 12 Comments

Tags

InfoPath

Issue

User get’s a listed below error when opening a new or existing InfoPath form because of an error in the form’s code

Error
“The required version of the Microsoft .NET Framework is not installed on your computer or the InfoPath Primary Interop Assembly (PIA) is not registered. Use Add or Remove Programs in Control Panel to make sure that the required version of the Microsoft .NET Framework is installed. Or install it using Windows Update and run the Setup program again to confirm that the corresponding version of the .NET Programmability Support is installed, or contact your system administrator.”
Cause\Resolution

As the error message suggests either the Microsoft .NET Framework or the InfoPath Primary Interop Assembly (PIA) is not installed. If Microsoft .NET framework is not present on the system then this will need to be installed. If the user does not have the .NET Framework already installed (when installing Office 2007) then PIAs will not be installed. Additionally, the option to install the PIAs doesn’t show up in the Custom setup for Office. If the user does a complete install of Office 2007, then PIAs will get installed into the GAC automatically. It’s strongly recommended that a complete install of Office 2007 be performed.

If .Net Framework is installed after installing Office 2007, then PIA does not get installed automatically and this can to be installed by following the steps listed below

1. Go to ‘Add or Remove Programs…’
2. Select the Microsoft Office 2007 installation and click on change.
3. Select “Add or remove features” and click Continue.
4. Expand the “Microsoft Office InfoPath” and “.NET Programmability Support” node. Add the ‘.NET programmability support’. To add, right click on the node and select “Run from my computer”. Press continue and follow the on screen instructions to complete the setup.

← Older posts

Pages

  • About Ken
  • Ken’s CV

Blog Stats

  • 1,635,087 hits

.Net 3.5 5566 AJAX BCS BDC C# Calendar Content Type CSS Custom Page Document ID Fast Search favicon Feature IIS InfoPath infopath form JavaScipt JavaScript jQuery LINQ Listview Managed Property Master Page MCP MCPD migration MOQ MySite Page Layout PowerShell Proxy Search Search Scope SharePoiint 2010 SharePoiint 2010; Search SharePoin Sharepoint Sharepoint 2007 SharePoint2007 Sharepoint 2010 Sharepoint Search Silverlight Site Collection Site Definition Site Master Page site templates SPDisposeCheck SPD workflow SPSiteDataQuery SPUser SQL SSP stored procedure STSADM survey Tab TechEd Tech ED TSQL User Profile User Profiles Synchronization Service;SharePoint 2010 vs 2008 vs 2010 vs2010 WCF web.config webpart Web Part Web Service windbg workflow XML XSL XSLT

Archives

  • March 2016
  • April 2014
  • March 2014
  • February 2014
  • December 2013
  • October 2013
  • September 2013
  • March 2013
  • February 2013
  • August 2012
  • June 2012
  • May 2012
  • April 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008

Twitter Updates

  • @telstra @outage @3125 internet cable still not working since 8:30 am 6 months ago
  • @Telstra is internet cable service still down in Burwood Vic 3125? Have been issue for a day! 6 months ago
  • Anyone uses @Nintex Workflow for SharePoint online has email issue? all our external email actions are hanging since yesterday. 9 months ago
  • @Nintex Hi, is your Workflow External Email service is down? Since yesterday afternoon, no email being sent out usi… twitter.com/i/web/status/9… 9 months ago
  • @Nintex just wonder if there is any SharePoint online workflow server issue right now? All workflows are not reachable 1 year ago
Locations of visitors to this page

Blogroll

  • E-books Library
  • My Linkedin
  • SharePoint Community
  • SharePoint Developer Center
  • Silverlight Show
February 2019
M T W T F S S
« Mar    
 123
45678910
11121314151617
18192021222324
25262728  
Advertisements

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy