Saturday, November 14, 2009

Developing with Office 2010 Services

Visio Services:

Get Microsoft Silverlight

Access Services:

Get Microsoft Silverlight

Excel Services:

Get Microsoft Silverlight

Word services:

Get Microsoft Silverlight

Sharepoint 2010 Developer Resources

SP2010

The first place, which you need to visit before starting Sharepoint 2010 development is here. Clicking on the modules from the right side bar you will have an access to related HOL (see below) and code snippets from Paul Andrew’s blog 

What’s new in Sharepoint development  with VS 2010 (Beta 2)

What’s new in Sharepoint Foundation 2010 

What’s new in Sharepoint Server 2010

Sharepoint 2010 Developer Hands-on-labs (download): Series of 10 HOL, which covers:

  • Web parts development
  • List definitions and Event receivers
  • Using LINQ for Sharepoint
  • Using Client OM and REST
  • Business Connectivity Services (BCS) External Content Type
  • Sharepoint 2010 workflow
  • Developing UI and Silverlight
  • Sandboxed solutions
  • UI Ribbon and dialogs development

Sandboxed solutions - Sandboxed solutions run in a secure and monitored process that has limited resource access

Extending Sharepoint tools in Visual Studio 2010 - You can create extensions for projects, project items, define your own project item types and create deployment extensions.

Feature and Package designer

Visual Studio 2010 and Sharepoint 2010 (drill down and navigate through the content categories)

Peter Jausovec’s blog (http://blogs.msdn.com/vssharepointtoolsblog/)

Monday, November 9, 2009

SUGBG (Meeting 7): No-code solutions with Sharepoint 2007

When: 11 November 2009, 18:30

Where: Microsoft Bulgaria office (Sofia, Blvd.”Nikola Vaptzarov”, 55)

Session 1: Enhance Sharepoint with no-code solutions

Speakers: Esad Ismailov, Miloslav Shulev and Veselina Evstatieva (BNP Paribas)

Download the presentation

Session 2: Enabling SharePoint business users: iTechnology Forms Accelerator and K2

Speaker: Petya Gaitanska (iTechnology)

iTechnology presented their fantastic product iTFA. They demonstrated the Silverlight form designer, the rules editor, integration with K2 workflow and answered all questions from SUGBG members. The very important notice here is: iTFA is free! Download and test from here (needs registration).

For more info (in Bulgarian) visit www.sugbg.org

Thursday, October 15, 2009

SUGBG (Meeting 6): Sharepoint for ASP.NET Developers

When: 21 October 2009, 18:30

Where: Microsoft Bulgaria office (Sofia, Blvd.”Nikola Vaptzarov”, 55)

Session: SharePoint for ASP.NET Developers

Level 200

Speaker: Radi Atanasov, Architect, Abilitics

For mo info (in Bulgarian) visit www.sugbg.org

Download the presentation

IMAGE_130

Wednesday, October 7, 2009

Sharepoint - InfoPath Error - “Some rules were not applied”

Yesterday evening I had a very strange problem with InfoPath form. When I tried deploy it to Sharepoint production farm I received the error that “some rules were not applied”. The same form worked perfect when I tested in InfoPath client against the same Sharepoint deployment. It is very important to say, that I’m using a call to UserProfileService and GetUserProfileByName operation. The production farm consist of three WFE and we found the following exception in the log:

w3wp.exe (0x15D8)                       0x17A8 Forms Server                     Forms Services Data Objects       13zh                Exception            System.Net.WebException: The remote server returned an error: (401) Unauthorized.     at System.Net.HttpWebRequest.GetResponse()     at Microsoft.Office.InfoPath.Server.SolutionLifetime.WebServiceHelper.GetResponseHelper(WebRequest request, DataAdapterTimer dataAdapterTimer, DataAdapterCredentials credentials, Stopwatch timer, ExecWebRequestExceptionState state, String adapterName, Boolean isQuery)     at Microsoft.Office.InfoPath.Server.SolutionLifetime.WebServiceHelper.ExecWebRequestSync(XPathNavigator inputSubDOM, Boolean[] inputUseDataset, XPathNavigator resultsSubDOM, Boolean resultUseDataset, XPathNavigator errorsSubDOM, Uri serviceUrl, Uri soapAction, Int64 timeOutMillisec, Solution solution, Document document, String name, Boolean isQuery, DataAdapterTimer dataAdapterTimer, DataAd...

Server platform: Windows Server 2003 x64, SP2

The solution:

Check http://support.microsoft.com/kb/926642 (Method 2: Disable the authentication loopback check) and add DisableLoopbackCheck key on each WFE.

After reboot it works!

Thursday, September 24, 2009

SUGBG (Meeting 5): Business Intelligence with PerformancePoint Server and MOSS 2007

When: 30 September 2009, 18:30

Where: Microsoft Bulgaria office (Sofia, Blvd.”Nikola Vaptzarov”, 55)

Session: Business Intelligence with PerformancePoint Server and MOSS 2007

Level 200

Speaker: Yordanka Dragieva, Consultant

For mo info (in Bulgarian) visit www.sugbg.org

Download the presentation

IMAGE_129

IMAGE_126

Sunday, September 20, 2009

Attach Files to InfoPath Form, (upload to Sharepoint library and generate links into form’s body)

Soon I have a task to create InfoPath form which has Attachment control, uploads file(s) to Sharepoint library and puts a link to it in the form’s body. I will describe the steps, which a used to solve the business scenario.

I choose to use Visual Studio 2008 instead of InfoPath client and created new InfoPath Form Template project.

image

I designed a form with following layout and data source:

image

image

Field Type Description
Title Text Required, Text Box
Attachment Picture or file attachment (base64)  
group4 Repeating table Two columns, Container for hyperlinks
Url Text Text Box with conditional formatting (see the settings below)

Conditional formatting for Url text box:

image

image

image

Select a hyperlink control from Toolbox, drag and drop it in the first column of the repeating table

image

and set up the properties like this

image

Finally, double click on “Attach File” button, open “Button Properties” dialog and select “Edit Form Code”. FormCode.cs should be open, go to Solution Explorer and add a reference to Microsoft.Sharepoint.dll

Right click on the project Add/New Item…/Code/Class and enter InfoPathAttachmentEncoder.cs for file name. Copy the source code for “Create an Encoder class in Visual Studio” from http://support.microsoft.com/kb/892730 and paste it in the new created file. Make the same for InfoPathAttachmentDecoder.cs

image

Use the following lines of code to upload attached file to Sharepoint document library (“Documents”), plug a hyperlink information into form content and store the form in Form library (“MyForms”)

 

        public void btnAttach_Clicked(object sender, ClickedEventArgs e)
        {
            XPathNavigator attachmentNav = MainDataSource.CreateNavigator();

            // Get the base64 encoded attachment
            string attachedFile = attachmentNav.SelectSingleNode("//my:Attachment", NamespaceManager).Value;
            attachmentNav = attachmentNav.SelectSingleNode("//my:Attachment", NamespaceManager);
            // Delete the encoded file form XML form
            attachmentNav.InnerXml = string.Empty;

            // Get the value of "Title" field
            string reference = MainDataSource.CreateNavigator().SelectSingleNode("//my:Title", NamespaceManager).Value;

            // Convert the base64 encoded string into a byte array
            InfoPathAttachmentDecoder decoder =
              new InfoPathAttachmentDecoder(attachedFile);
            byte[] attachment = decoder.DecodedAttachment;
            string fileName = decoder.Filename;

            // Add the file as an attachment to the SharePoint list item
            using (SPSite site = SPContext.Current.Site)
            {
                if (site != null)
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        // Turn on AllowUnsafeUpdates on the site
                        web.AllowUnsafeUpdates = true;

                        // Add the attached document to "Documents" library
                        // and set the value of "Reference" column to
                        // "Title" filed of the InfoPath form

                        SPFolder lib = web.GetFolder("Documents");
                        SPFile file = lib.Files.Add(fileName, attachment, true);
                        file.Item["Reference"] = reference;
                        file.Item["Title"] = fileName;
                        file.Item.Update();
                        file.Update();

                        // Add attachment file url to "Url" field in the form
                        // by adding extra "my:group4" element in the form

                        XmlDocument xdoc = new XmlDocument();
                        xdoc.LoadXml(MainDataSource.CreateNavigator().OuterXml);

                        Uri url = new Uri(new Uri(web.Url), file.Url);

                        XmlNode grp4 = xdoc.SelectSingleNode("//my:group4", NamespaceManager);
                        XmlNode clonedNode = grp4.CloneNode(true);
                        clonedNode.SelectSingleNode("//my:Url", NamespaceManager).InnerText = url.AbsoluteUri;

                        grp4.ParentNode.InsertAfter(clonedNode, grp4);
                        string formXml = xdoc.OuterXml;
                        // Add the form to "MyForms" library
                        SPFolder formlib = web.GetFolder("MyForms");
                        string formName = string.Format("Request {0}.xml", reference);
                        SPFile form = formlib.Files.Add(formName, Encoding.UTF8.GetBytes(formXml), true);
                        form.Item["Title"] = reference;
                        form.Item.Update();
                        form.Update();

                        // Turn off AllowUnsafeUpdates on the site
                        web.AllowUnsafeUpdates = false;

                        // Close the connection to the site
                        web.Close();

                    }
                    // Close the connection to the site collection
                    site.Close();
                }
            }
        }

After publishing the form and administration approval from CA site I associated the new created Content Type with existing Form library (“MyForms”).

The results:

The initial form’s XML. <my:Attachment> inner text (the encoded file) is very big and Visual Studio hides it from the preview screen

image

The content of <my:Attachment> here is removed

image

The final form’s XML, with attached file URL

image

The empty/new form

image

The final form

image

The uploaded documents

image

The forms library

image

Download complete Visual Studio project