A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Sunday, January 27, 2008

Office SharePoint Designer 2007 Step by Step, is now in the book shops pre

Microsoft Office SharePoint Designer 2007 Step by Step is now available in the market. The book targets the Information workers. Introduction of the book can be read on the author's (Penny Coventry) blog:
Microsoft site also has some details on the book:
I will post a review of this book as soon as i get a copy.

-SSA

Sunday, January 20, 2008

Links for Workflow with VS 2008

People have already started blogging about the workflow creation with VS 2008. Here are a couple of cool links that show how to create sequential workflows using VS 2008:
Webcast:
Also, do read the following good article about VS 2008 written by Dino Esposito:

-SSA

Tuesday, January 15, 2008

InfoPath Error: The given key was not present in the dictionary.

If this error occurs when you try to submit the form, then there can be two reasons for this. The data connection name is not correct or the URL used in the data connection is not correct. Sometimes, it is hard to pin point the problem because the URL will not be accepted if it has a problem, no matter how minor. An extra space, an illegal character, etc are the problems that are hard to locate and are the source of this error. This usually occurs when you try to submit the form programmatically because directly publishing the form to the SharePoint allows you to select the site and library so there is no chance of entering a malformed URL but when you submit the form programmatically using a data connection, you have to provide the URL manually. The details of the error are as follows:
------------------
 The given key was not present in the dictionary Source: Microsoft.Office.InfoPath.Server Stack trace:   at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.ExecuteOMCallWithExceptions(OMCall d, ExceptionFilter exceptionFilter)
   at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, ExceptionFilter exceptionFilter, OMCall d)
   at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMSecurityContext.ExecuteOMCall(Solution solution, SecurityLevel methodSecurityLevel, OMCall d)
   at Microsoft.Office.InfoPath.Server.DocumentLifetime.DataConnectionCollectionHost.get_Item(String name)
   at function() in Pathcode.cs:line 394
   at function() in Pathcode.cs:line 290Location:Void ExecuteOMCallWithExceptions(Microsoft.Office.InfoPath.Server.DocumentLifetime.OMCall, Microsoft.Office.InfoPath.Server.DocumentLifetime.ExceptionFilter)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
---------------------------
Code to submit form programmatically:
 public void FormEvents_Loading(object sender, LoadingEventArgs e)
 {
       string srcLoc = e.InputParameters["Source"].ToString();
       srcLoc = srcLoc.Substring(0, srcLoc.IndexOf("/", 8));
       libLoc = srcLoc + e.InputParameters["XmlLocation"].ToString();
 }
FileSubmitConnection SubmitConnection = (FileSubmitConnection)this.DataConnections["Mainsubmit"];
SubmitConnection.FolderUrl = libLoc.Substring(0, libLoc.LastIndexOf("/"));
SubmitConnection.Execute();
"Mainsubmit" is the data connection name. If there is a spelling mistake in this name, you will get the error. If there is a spelling mistake in the URL used in this connection, again there will be an error. You need to be extra careful when publishing the form. It is hard to notice the problem because the form publishes OK with out any problems and you only get the error when you run the form from SharePoint.

InfoPath: Delete file attachments programmatically (C#)

There is a section in your form that file attachment control or you can have attachment controls in a repeating table to allow multiple attachments and if you want to delete the file attachments using C#, here is the solution:
   XPathNavigator files = this.CreateNavigator().SelectSingleNode("/my:myFields/my:RepeatingGroup/my:FileAttachments", this.NamespaceManager);
                    XPathNodeIterator Node_2b_Deleted = this.CreateNavigator().Select("/my:myFields/my:RepeatingGroup/my:FileAttachments", NamespaceManager);
                    string attachments = "/my:myFields/my:RepeatingGroup/my:FileAttachments";
                    XPathNavigator firstItem;
                    XPathNavigator lastItem;
                    if (Node_2b_Deleted.Count > 1)
                    {
                        firstItem = files.SelectSingleNode(attachments + "[1]", NamespaceManager);
                        lastItem = files.SelectSingleNode(attachments + "[position()=last()]", NamespaceManager);
                        firstItem.DeleteRange(lastItem);
                        lastItem = null;
                        firstItem = null;
                    }
                    else if (Node_2b_Deleted.Count == 1)
                    {
                        firstItem = files.SelectSingleNode(attachments + "[1]", NamespaceManager);
                        firstItem.DeleteSelf();
                    }

                    Node_2b_Deleted = null;
                }
You define the XPath that points to the file attachments. You take the first node (attachments[1]) and the last node (attachments[position=last()] and delete the attachments:
firstItem.DeleteRange(lastItem); where first item points to the first node and lastItem points to the last node. If there are more than 1 attachment, then DeleteRange() is used but if there is only attachment, then you can use DeleteSelf() to remove the only node.
That's it. Confusion? Contact me!

Wednesday, January 2, 2008

Sorting repeating table


I have already given a programmatic solution of sorting a repeating table in InfoPath but here is another way of doing it: