tag:blogger.com,1999:blog-4290256224342591522024-03-18T11:48:36.437+02:00SharePoint RootsCenter for responsible SharePoint DevelopmentJohan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.comBlogger57125tag:blogger.com,1999:blog-429025622434259152.post-87615446425530080442014-07-31T09:55:00.001+02:002014-07-31T09:58:16.459+02:00Top SharePoint Blogs<div id="ly_wrap_2yJ" style="text-align: left;">
<span id="ly_wrap_2yJ_t" style="display: block; margin: 10px 0 4px;">Check out a very helpful list of SharePoint blogs to help new and experienced developers, business users get up to speed. </span><span id="ly_wrap_2yJ_t" style="display: block; margin: 10px 0 4px;"><img alt="SharePoint Blogs" src="http://media-cdn.list.ly/production/11427/blog-4860765273.png" /></span><span id="ly_wrap_2yJ_t" style="display: block; margin: 10px 0 4px;"><br /></span><script src="https://list.ly/plugin/show?list=2yJ&layout=full&show_header=true&show_author=true&show_tools=true&show_sharing=true&per_page=25" type="text/javascript"></script><br />
<div class="ly_wrap_f" style="padding: 4px 0 10px;">
<br /></div>
</div>
Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com5tag:blogger.com,1999:blog-429025622434259152.post-85183927438228991122013-10-16T18:43:00.001+02:002013-10-16T19:07:35.753+02:00SharePoint Code Check (SPCop) first impressions<p><a href="http://visualstudiogallery.msdn.microsoft.com/c991a9ed-7a7b-465f-9be3-923443fd6e7b" target="_blank">SharePoint Code Check (SPCop)</a> which is the free SharePoint code analysis component of <a href="http://visualstudiogallery.msdn.microsoft.com/d3b2aaf7-0d6a-4995-a4e5-4153c57e3889" target="_blank">SharePoint Code Analysis Framework (SPCAF)</a> was released in the first week of October 2013. <br /> <br />I had a quick test-drive and this is what I found.. <br /> <br />Historically I used a combination of <a href="http://www.microsoft.com/en-za/download/details.aspx?id=6544" target="_blank">FXCop</a> , <a href="http://www.microsoft.com/en-us/download/details.aspx?id=19968" target="_blank">CAT.NET</a> , <a href="http://stylecop.codeplex.com/releases/view/79972" target="_blank">StyleCop</a> and <a href="http://archive.msdn.microsoft.com/SPDisposeCheck" target="_blank">SPDisposeCheck</a> to ensure my custom code meets industry standards and best practices for SharePoint development. <br /> <br />As a SharePoint Architect I am constantly looking for ways to make it easier for our team to build reliable, robust and quality code. Code analysis tools are essential in our development lifecycle and I also find that a set of analysis tools is a very valuable training mechanism for ASP.Net developers to make the transition to SharePoint development. <br /> <br />SPCop is a great tool for ensuring the highest possible level of quality code is produced as it consolidates the functions of many of the individual code analysis tools into a single tool. It also allows the developer to analyse the XML code in SharePoint packages like Features, ContentTypes, ListTemplates and all the other files like controls (.ascx), pages (.aspx) and master pages (.master), stylsheets (.css), JavaScript (.js) etc. <br /> <br />The great thing is that SPCop can be used directly in Visual Studio 2010/2012/2013 which eliminates the need for the developer to first compile assemblies and run command-line tools to analyse the code. The results of the code analysis are displayed in the Visual Studio Error List which makes it quite convenient for the developer to navigate and repair issues. <br /> <br />As an example I used Visual Studio 2010 to create a C# SharePoint 2010 Empty SharePoint Project and I added a Feature with a Feature Event Receiver. I did not add any code to my project. Because I haven’t written any code yet I would trust that the (almost empty) project meets the appropriate standards but when I ran SPCop I was quite surprised as to how many valid warnings I received. (Imagine how much this would help a new SharePoint developer) <br /> <br />The results are shown below: <br /> <a href="http://lh3.ggpht.com/-lfXaqPM4AUY/Ul7CC0XVwLI/AAAAAAAAA3s/hvONSz88yH0/s1600-h/image%25255B10%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJi5ihUoIC51uA_XkP3Bnu30lAPyJ5qt5krb3sx46V-7tvMVKDjdUcTN4IRyh2B04FQw7sYnLmL3qeySFAFAxHuKfxWSwTPWlRS0auQsbcTiZBSc1o5SWQHBg6rApsmiVKwFnqUKrz6i8/?imgmax=800" width="554" height="208" /></a> <br />This means that, even before I start writing custom code I can analyse the configuration of my project to ensure everything is in place. <br /> <br />The normal behaviour in Visual Studio is that if a developer double-click on an error or warning in the Errors List, the code window will open at the location where the issue need to be addressed. What I like about SPCop is that because it is designed specifically for SharePoint it also has the ability to navigate the user into some of the SharePoint configuration windows. As example, in order to fix the deployment scope, the user is immediately presented with the Package editor window. This is something which I haven’t seen in other SharePoint tools and it is very helpful. <br /> <br /><a href="http://lh6.ggpht.com/-kbjkK4eUg3Q/Ul7CEfQW3UI/AAAAAAAAA38/epS6TyLakVk/s1600-h/image%25255B18%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGEP6vql1-GludzZuMbKkY-Dh7E1lfcGlAFuOlrqu_3UyYUYwl5nqU8aQzMOQJa-cxd4ms9TZ5PGTgEiWL5jngLYSxqh2O_mmt81Xkh3DSoGfOlgkXL5wzh8HwthpS4HXto-6PMOWIBZw/?imgmax=800" width="554" height="501" /></a></p> <p>One of the Visual Studio solutions which I am currently working on contains 16 Visual Studio SharePoint projects. There are times when I want to run SPCop for only a specific project but there is also the need for me to run SPCop on the entire solution and consolidate the results of the code analysis of the 16 projects into a single MS Excel report. <br /> <br />To run SPCop against a particular project all you have to do is to right click on the project (in Solution Explorer) and select “Run SharePoint Code Check” <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTQQ-ACfqzaXKIi-JlTwOOjBAtXLEuHd9yon7ydnCP6tNy8RPmdve4S0L4UGRFTCEbc8tqsoqPmUgbhGxb_QVqmns1dsvGwOs7Vv2dH-lhz4T9VoQYPCEJ00H_0AdJYgcilmILdAZOmu0/s1600-h/image%25255B22%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEav3NSKLPE4Vn2nvaIR1twZz_d3EMSHgBbYeMzFGAQmxsT3mZ47uLVQs5s-9GabVOeJV1b_xvxTrkn5TxQYkFP-wCmpG-1x87yYC64pUAYXOCNBR4XVh_MUvqHuXStb2C_XjaAn6dSgc/?imgmax=800" width="554" height="265" /></a></p> <p>To run SPCop against all projects in a solution, simply right click on the solution instead of a project. <br />  <a href="http://lh4.ggpht.com/-w8lATdY8ODw/Ul7CHTLw7cI/AAAAAAAAA4c/cHpPGAo_CaY/s1600-h/image%25255B26%25255D.png"><font color="#333333"> </font><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY5j2_rOkf_YVwOf6KUtl9N9ejKZGILZOwzVt8JP-bc2oNKpQAeQZPu03tb9D87aEQOQ3q0HGe7f7qkfQIUNJnrGdf96ijm-1I8fqgvVUC6K_nVWSkMoyC7eHjSYUr78i644U7y72-B8Q/?imgmax=800" width="554" height="284" /></a> <br />  <br />The output can then be copied from the Errors List into Excel (for analytics, reporting, etc.) <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPXzbiI8zZxR8TIg2672Qq8bbzu1tDAqbgzIg3NF59wP1Vhv-2A79ML3rftdaH5i5OzSSOq0yVfPNCTUn6i3HRITYVqmEHeVcqjnsSE3dZozQ2b7j-1GY_FA3ee4QSp9kOmcCthVYHrkw/s1600-h/image%25255B31%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfAQQduJJW5-BjeGPmxzXE3XdnxK7L67sZCuKF6K607_qHHvVEBXN0o_LMgvJItC4UnhEHYbmoxZ7vpABN6DcI7YUyZeuznK6013JWQOEP6Bl4sYUvT-M7S-CBJ6yZLGI9g6rmMQHGQl0/?imgmax=800" width="504" height="437" /></a></p> <p>When I speak to development teams about code analysis tools and ALM, one of the first questions I always get asked is whether it is easy to customize the rule sets (the rules which the code analysis is based on). Face it, no development house is the same and no project is the same, so there will always be a need to make small modifications to the rule sets. <br /> <br />In Solution Explorer (in Visual Studio), right click on your SharePoint project or solution and select the SPCop Ruleset command. This will allow you to select a pre-defined rule set, modify an existing rule set or create a new custom rule set. <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCCdPh5uMs3SUBFgc6r8PMsvuS_9-CHsqEmrWQ7rD1Ud-I_t-4Ush0-2KDPAElSkom50pqu4xO9NE0FGM4ouUy3jIx2dKUDPC8RiQ7MWXk32YSX4fu3Doqv48G03s-m4xxa6wI1ivv1-s/s1600-h/image%25255B35%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnazjQOzzZwuGJH4d6Oj2kkAOt1fvLYTp-g9Cj9OKgMh9s1G5Azqcld8J3p-dehCD_C3aGw9mY8Mscqgq8dZqjuEHRiYo5duf4LdS-MqMlXnyLgtWVaDktK1Iq5OF-68fkPnlTOwWeFO0/?imgmax=800" width="554" height="318" /></a> <br /> <br />The SPCAF Ruleset Editor is used to modify existing or create new rule sets. <br />I appreciate the Schema and Help URLs which are available for the existing rules and actually think I want to encourage my fellow developers to use these as a study guide..whooohoo!!! <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1vRYAJNhHTCMhpFXqaRpDQEWZI0-2cAwDnPtYlE3KSAgYkXqnLu0e12SF-ujS2tuqL1VeWcF-tm6XM_w-wJct5WALq7KpaAkKowGNMdO-WzODdZ6TR3T_ihqi_Jx1GVPJSWRU0iXahhg/s1600-h/image%25255B39%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdonNtVjJ0_xDll79VHy4OmCWqrqB1xgcjjbblveWEUbm4LDSF056CfKJkU-rUB4dIGoBM3YA1nsx2elsztYKdgrURh7c9wFyLCUO2kws5X08NRHMq0QAWpCSI4FNp_GubA0UZ6p31f9s/?imgmax=800" width="554" height="362" /></a></p> <p>Overall I am immensely impressed with this (free) tool and I have no doubt that this tool will become the core of my code quality assurance. <br /> <br />Technological advancements, lack of experience,  moving into the SharePoint development realm (from traditional ASP.Net), etc. are only some of the challenges we face. This along with deadline pressures, demanding projects, complex work situations, etc. make it very difficult to excel and obtain a sense of achievement so encouragement, resources, learning materials and great tools are essential for us to be successful. <br /> <br />Having the right tools at hand makes an enormous difference in the life of a SharePoint developer and I am grateful for <a href="http://www.matthiaseinig.de/" target="_blank">Matthias Einig</a> and the <a href="http://www.spcaf.com/company/" target="_blank">RENCORE AB</a> team for making SPCOP available. Thanks guys!! <br /> <br />Related - please see my blog post: <a href="http://johanolivier.blogspot.com/2013/10/why-microsoftofficeserversearchdll.html" target="_blank">The reason why Microsoft.Office.Server.Search.dll prevented me from using SPCOP to analyse code</a>.</p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com4tag:blogger.com,1999:blog-429025622434259152.post-56298032268951060752013-10-16T18:01:00.001+02:002013-10-16T18:33:09.176+02:00Why Microsoft.Office.Server.Search.dll prevented me from using SPCop to analyse code.<p>I recently evaluated <a href="http://visualstudiogallery.msdn.microsoft.com/c991a9ed-7a7b-465f-9be3-923443fd6e7b" target="_blank">SharePoint Code Check (SPCop)</a> and I quickly came across a problem whereby I was unable to run SharePoint Code Checks on certain projects. </p> <p>The problem was that SPCop would initiate the build but then, before the code analysis started, the following error would be shown in the Visual Studio Output window:</p> <p><font color="#ff0000">SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.Office.Server.Search.dll.</font></p> <p><a href="http://lh5.ggpht.com/-JB93ZWZ50Lg/Ul66XXp919I/AAAAAAAAA1k/6mSQk-w_0t0/s1600-h/image%25255B46%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-kFOOs6bd5IM/Ul66YCKKCiI/AAAAAAAAA1s/6uchaAiPXwA/image_thumb%25255B28%25255D.png?imgmax=800" width="504" height="223" /></a> <br />  <br />The good news is after a bit of investigation I found that the issue has absolutely nothing to do with SPCop and it is actually quite an old SGEN and SharePoint 2010 custom development problem, so if you come across the same problem, don’t associate it to the new release of SPCop … I know it is easy for a developer to download software, install it and then consider immediate problems as something which was caused by misconfiguration or that there might be a known issue with the new release.. </p> <p>This problem is not because of SPCop!!</p> <p>This post will explain the detail of the issue and how to work around it.</p> <p>Scenario: <br />    I have a Visual Studio 2010 SharePoint project which contains: <br />    • a reference to Microsoft.Office.Server.Search.dll and <br />    • a web service reference <br />      (in this example a reference to SharePoint Authentication service at                       http://SiteCollectionURL/_vti_bin/Authentication.asmx)</p> <p>I am busy with development and I can successfully build my project in debug mode. <br />  <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfND7BuGSh8rQ74gBHQ7aN7NRRXmpunonPUBevkadAp74I8Pu6Z99g7Hb-XqlAmtsAVNIqlbZdu3Nv_-s_aX3Rr8CQU9bLfJktXqVdve3geX_V6kZeelEjyjhZHCIRtN62DLUNDoL7lSU/s1600-h/image%25255B59%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiakN9DGzvUcvVEQHGS41Og_361orG3QN-89m7ts1i_LVy0WK1jobWfkGruqJ8OztAko6OpJCmIxkUT3IeWBCzEP-AOdSBKOZbigCQH5HJDVB72m1oQA1k7ZQIE6jVBWcWWoleUBgyiiJ8/?imgmax=800" width="604" height="102" /></a> <br /> <br />I then try to run SPCop.. Right click on project, select SharePoint Code Check and then click on “Run SharePoint Code Check” <br /> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiQeH92iMK4r43fkEeAnZyddus7CUXOMfg5ZUTS_OzkcVeepH6eO-t-LKMFEWL-sxCpj7fEF_lp9NBPpVyZ2z8KaW1Fef1XeZ4MEzjZK8SwXKTqPI3bZ56IhbwL58DXZa1WXOOccTtN8o/s1600-h/image%25255B38%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyQyiDOlOygsTvCrVRvDL_v3LgSjNBcs2C63gxcpnm1vrBjk-rqi4yuFIYljDgrm5Qpdk_t3rTDChxlrlVoZQOXm87qnh2jTCj8qjSW3ap0j93BMZHz5xR1uvQ8ZEQGBT3TBLuQwJ_A5s/?imgmax=800" width="604" height="434" /></a>  <br />SPCop starts to create a new build but then fails and I am unable to analyse my code :-(</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgPyK53vdKvd9Pg3Md38-CkDNAsU1wzVoRPEpf_3om6ZtVnmpYp_R0f04_0S-bMoZzIR-_ZLaWSRzJS3LrMHncljkgTC4uxQ3E7CbpkF6gjWjhFFxb92hiUSo1_vd3tD2PmcXpb6NGDJc/s1600-h/image%25255B61%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-pY-Sp1ruW5I/Ul66alXw1qI/AAAAAAAAA3A/CI1qAVcD1mw/image_thumb%25255B36%25255D.png?imgmax=800" width="504" height="223" /></a></p> <p><strong>Why?</strong> <br />Before SPCop analyses your code it builds and packages the SharePoint project to create the .wsp file which it then inspects. During the build process SGEN actually fails. It is not SPCop which fails. <br />I was able to build and package my project in debug mode so why is SPCop unable to build the same code? <br />After a bit of investigation I realized that SPCop will build the project in RELASE mode even though my project configuration is set to DEBUG mode. This is actually great because before I finalize my code I need to build and test it in release mode anyway.</p> <p><strong>Why did SGEN fail?</strong> <br />If your project contains a reference to Microsoft.Office.Server.Search.dll and a reference to a web service SGEN will fail to generate the serialization classes. <br />This is due to Microsoft.Office.Server.Search.dll not being a MSIL dll but instead being specifically compiled to run on AMD64. I guess this means that SGEN is unable to reflect on it and build Serialization classes. <br />If you set your project to release mode and go to your project properties page, you will most likely notice in the Output section the setting for “Generate Serialization Assembly” is set to “Auto”.</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqm9frTBT4s7lOTQq80ZUl_PN5B-n096NklHQBf1uqmfzRL86aaYkn3tkjBBpS-thW-v2P6FMuyqFZvWyimodtH3gC2p6Xiwg5BE6vJdbpFcgm2nmYL_LCW8QUxpo9aOVnD6RucTVmC4Q/s1600-h/image%25255B40%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip0xEuhG25w7kd1BXLDJDVNwZ5XMpd_KqimUt2WGBuoLrVBpgeIWUTHkW2kAb8TmYUYyzis1gSISXjBwIY_RsprpiM00Coxl_MDBefyqMThZxHnP-IVTE90FeAM_5kkCzK-qFwzV1A7xo/?imgmax=800" width="354" height="157" /></a> <br />The interesting thing is that when the setting is on Auto the following applies: <br />    • When build in debug mode: Generate Serialization Assembly = OFF <br />    • When build in release mode: Generate Serialization Assembly = ON</p> <p>So, this explains why we can build in debug mode but not in release mode. And, because SPCOP builds in release mode it explains why you will receive the same SGEN error.</p> <p><strong>Proper Solution</strong> <br />I haven’t found a solution for building projects which contains both a reference to Microsoft.Office.Server.Search.dll and a web service reference in release mode. I assume that because of this issue one would build in debug mode and then use SGEN.exe to create the serialization assembly and then include the assembly in your package.</p> <p><strong>There is a Work Around</strong> <br /> <br />The work around is to set "Generate Serialization Assembly" to "Off" on the project properties for the release build configuration. <br /> <br /> <a href="http://lh6.ggpht.com/-11yIYmlqVHk/Ul64PpOdASI/AAAAAAAAA1E/VC6TnKRl3mU/s1600-h/image%25255B41%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-Ec_EkKjG18g/Ul64QV0MBgI/AAAAAAAAA1M/bWz6VEn8XzY/image_thumb%25255B25%25255D.png?imgmax=800" width="354" height="147" /></a> <br /> <br />Once you changed this setting and saved the project you will be able to successfully analyse your code with SPCop <br /> <br /> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMz2oJi7MzL5us7X_qlNacrzr-9N-l0qeraKltluzQyuJiJXq4eDJ4szGwXskqjwp3qruvinRGb8vnOEzko8DXyNfs5quhxFPaZE5uHDcKa8qttxDpVvZ4WYbNohw9Z3NULAhwrw5ihps/s1600-h/image%25255B77%25255D.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBgST4d6GSL6YSBhmdWXAJjwKlJZTZPLRu8GL6PJ0_9tOQ1OmAgO-PadNyTIsvGSvVqNRG26cLGNO_IELXuiA5uYFzrV4HgC2k8-uighJAyQA8KAT6Mshzv-4h1ZjH2K4qS_me8KnXkcc/?imgmax=800" width="504" height="260" /></a> <br /> <br />My concern is that if we set "Generate Serialization Assembly" to off, XmlSerializer will generate serialization code and a serialization assembly for each type when the SharePoint web app runs for the first time (example, after server reboot or IIS reset). Because this happens only once it is not a huge performance issue, but nonetheless, I would still like to find a proper solution.</p> <p>Enjoy!! </p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com4tag:blogger.com,1999:blog-429025622434259152.post-40888709462594765172013-10-10T14:49:00.001+02:002013-10-10T14:55:39.452+02:00Solved: “The collection cannot be modified” error on Content Type Update.<p>I recently came across a problem whereby an exception is thrown when Update() is called on a SharePoint 2010 content type. <br /></p> <p>Let me explain the scenario… there are two ways to retrieve content types, those are: </p> <p>1- <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.contenttypes(v=office.14).aspx" target="_blank">SPWeb.ContentTypes</a> which gets the collection of content types for the website. <br />When you are referring to an SPWeb object and need to go through the content types for that web, the SPWeb.ContentTypes property will <strong><u>only</u></strong> show you a list of content types that have been defined at that site level, not a full list of Content Types that the web has available to it.</p> <p>and</p> <p>2- <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.availablecontenttypes(v=office.14).aspx" target="_blank">SPWeb.AvailableContentTypes</a> which gets the collection of all content type templates that apply to the current scope, including those of the current website, as well as any parent websites. Use the AvailableContentTypes property if you want to get the list of all content types that are available to the web (including all of those defined at sites above it in the site structure, all the way to the top of the site collection).</p> <p>Because I wanted my code to retrieve the content type regardless where the content type was available (current web or root web / site collection level) I used SPWeb.AvailableContentTypes.</p> <p>To illustrate this I created the following very simple C# console app which uses the SharePoint object model to move a custom content type from one group to another.</p> <p>So the following code should return the content type and allow me to update it... but it won’t work...</p> <p><font color="#0000ff">using (SPSite site = new SPSite(demositeURL)) <br />{ <br />    try <br />    { <br />        SPContentType contenttype = site.RootWeb.AvailableContentTypes["Demo Content"]; <br />        if (contenttype != null) <br />        { <br />            contenttype.Group = "Demo Content Types"; <br />            contenttype.Update(); <br />        } <br />    } <br />    catch (Exception e) <br />    { <br />        System.Diagnostics.Debug.WriteLine(e.Message); <br />    } <br />} <br /></font></p> <p>If I run the code, SharePoint throws a <font color="#ff0000">“The collection cannot be modified.”</font> Exception on contenttype.Update();</p> <p><a href="http://lh4.ggpht.com/-SAZ12x-q3uA/UlaiTwA6ZYI/AAAAAAAAAxo/kudvnD6ewFw/s1600-h/image%25255B3%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqjkfYixFjzNTfizoUiPgtqluL5cnu7qeagQPNoYlc9g0lc30SwYGs5JYNXf8ppLJboqPD1BeBlEDeahdPCt5t2qo_nL8alhi01iZY4Nuw1XQ9AbPNK-2QiPCYz8X7uEHCVARhHRRW83M/?imgmax=800" width="504" height="171" /></a></p> <p>Thanks to <a href="http://bernado-nguyen-hoan.com/2012/01/13/spexception-the-collection-cannot-be-modified-when-calling-spcontenttype-update/" target="_blank">Bernado Nguyen-Hoan</a> I found that you have to ensure that the content type you are updating was not retrieved from the SPWeb.AvailableContentTypes collection. Content types retrieved from this collection (as oppose to SPWeb.ContentTypes) are read-only. <br />SPWeb.AvailableContentTypes has a non-public property called ReadOnly and its value is true. Therefore content types retrieved from this collection also have a non-public property Collection.ReadOnly – which is also true.</p> <p>So if you need to update a content type, rather retrieve it from the SPWeb.ContentTypes instead of retrieving it from SPWeb.AvailableContentTypes.</p> <p>If you modify the code example from above and change this line:</p> <p><font color="#0000ff">SPContentType contenttype = site.RootWeb.AvailableContentTypes["Demo Content"];</font> <br />to: <br /><font color="#0000ff">SPContentType contenttype = site.RootWeb.ContentTypes["Demo Content"];</font></p> <p>The code will execute successfully.</p> <p><font color="#0000ff">using (SPSite site = new SPSite(demositeURL)) <br />{ <br />    try <br />    { <br />        SPContentType contenttype = site.RootWeb.ContentTypes["Demo Content"]; <br />        if (contenttype != null) <br />        { <br />            contenttype.Group = "Demo Content Types"; <br />            contenttype.Update(); <br />        } <br />    } <br />    catch (Exception e) <br />    { <br />        System.Diagnostics.Debug.WriteLine(e.Message); <br />    } <br />}</font></p> <p>Enjoy!!!!</p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com0tag:blogger.com,1999:blog-429025622434259152.post-46810429054489030482013-09-04T16:06:00.001+02:002013-09-04T16:23:00.328+02:00Solved: SharePoint 2013 Fails to render images after upgrade<p>I recently upgraded a SharePoint 2010 custom solution to SharePoint 2013. One of the issues I came across was that on certain custom pages the images no longer displayed correctly. Instead of displaying an image, the page or control would be blank or the user would be prompted to download a file. The same code worked on a SharePoint 2010 farm and I could not find any obvious exceptions in the SharePoint logs.</p> <p>In order to illustrate the problem (and solution) I created the following simple custom project: </p> <p>My example project contains a SharePoint 2010 Visual Web Part which contains one button. The button uses JQuery to show a custom page from the _Layouts folder. The custom page contains code-behind which will display an image from the current web “Images” library.</p> <p>I tested the solution in Visual Studio 2010 and all worked fine. When the user click on the button, the custom page is shown and it renders the image as expected.</p> <blockquote> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkd5GaTv-kbVkjAgstn81y0Vr6SuNVpb1pz6IvloYxnC235-9mK5mjnpKC_feP49_7wYmZiWJxV9gvmwrJVlUdh5zDX4RTcBbnq4YjlYM-Ce60bVMWIO8RXFG8UBBuIQzu_hc6gZKg7zE/s1600-h/image%25255B7%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf82oxlftzrRiGMyo0NAQV32DlVuuTzSD6kqvJIkEzQHzNYo2SjdjJ6aR85JQ9fJL3qVx-6ELUjVaWKblJN_fIWfHB1C1ZxC8G3etxPiLudhgqfR9HuhfqwiLB3r9_1bf4JtNASPMW8Kc/?imgmax=800" width="454" height="332" /></a></p> </blockquote> <p>However when I build and deploy the same project in SharePoint 2013 the custom page does not show the image, instead the user is prompted to download a file.</p> <blockquote> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiP2Fcwg7TAVSoWzAY3QdY2b3XJxBhZAaxI6NW6l-iORWm1SV2-Kzur8NZn6Q67UQcoN733WIhf3hSRnNq-4PiVzO2K9yJhKOOZguLWmAF5yPEIHrRoO6RJOw_2GxLeyHB1IZah2T4LkfA/s1600-h/image3%25255B1%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjruOzXu4gkycT3yezgekwC0f_4rQZDRxCPYvWngBEKqsrwZXprlalu5IZ0XCIUncV82yRdzqWq806jaYfeNzCz_VTROSuH6QBPXQSjy9E9dC574l78S8NQS80OHuRVGkm2PbnxrTb1jHk/?imgmax=800" width="454" height="263" /></a></p> </blockquote> <p>My colleague Hennie van Wyk quickly discovered that there is a difference between the SharePoint 2010 and SharePoint 2013 Web App’s HTTP Response Headers in IIS.</p> <p>If you open IIS Manager and go to the HTTP Response Headers of the relevant SharePoint Web App you will see that in SharePoint 2013 two new host headers are introduced. </p> <p>They are “<strong>X-Content-Type-Options</strong>” with a value “<strong>nosniff</strong>” and “<strong>X-MS-InvokeApp”</strong> with a value “<strong>1; RequireReadOnly</strong>”. </p> <blockquote> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCY1fIHhlv2gVH4eGypJ465GinQWwKF2qIk6eF3-I0flYpQ_3F_y4V9cDX22Co_B8jR0kxZCqxQoQwQ6Ipofhzdlljqw3kmm2AcLOR6UcWuVJx8Xn-vQHpuwvnUwz0mYvejN9-2g15AI4/s1600-h/image6%25255B1%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHWmTA2iCpIc0kCPDDRR5Li1tv8g9sIEhteUIFMTvYVs3v9whI-i2wzs6NxD8DZHmW7K00RcbAgIKq6x1YLZyD5nuJVo7QoPNq_RbFAHuzYVkSXpGxyVYe5lpwvYP9MGUZgmeLsOyUGJo/?imgmax=800" width="454" height="113" /></a></p> </blockquote> <blockquote> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4WQirmECZvsr-lOWuYau81fmFN8nY0mor5Cylxcpcotm8HcHpg0ljjTS65V6FwjkCaxr3YsvPD3v9maOhDaYgVD6GTLMUapdDyqh9ew4xGVBB9dSD2lcBFE-vGXX7-ng5qJsfw1mALL0/s1600-h/image9%25255B2%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxT_F6HBhTJfISi8Smemhss18rOmG_Ji3agdCLqWrJ-EPHCG06Aiwcuk5_QQP3ZbUNg9r9L6lT7XvcwOxAohWOwtbFGb4GDmii8kFd4uxU_cfNQa0dgbk4-RRqxyvRSSV0CfirqX1DrXg/?imgmax=800" width="454" height="111" /></a></p> </blockquote> <p>We further discovered that if we delete the X-Content-Type-Options response header the custom code worked and the images displayed on the custom page. I do not want to delete or disable standard SharePoint configuration and I certainly cannot expect my customers to do the same so I decided to investigate the possibility of changing the custom code so that it renders the new image regardless of the “X-Content-Type-Options” response header.</p> <p><strong>So, what is the X-Content-Type-Options response header?</strong></p> <p>I found <a href="http://sharepoint-community.net/profiles/blogs/sharepoint-2013-and-ie10-nosniff-beware">a very helpful blog post</a> by <a href="http://sharepoint-community.net/profile/markjones">Mark </a><a href="http://sharepoint-community.net/profile/markjones">Jones</a> in which he explains that the X-Content-Type-Options response header with a value of “nosniff” is a directive from IIS that tells the browser to <b><u>not</u></b> sniff the MIME type. When this is disabled IE won't try to automatically determine what your content is. E.g. HTML, PNG, CSS, script, etc... <br />This means that it’s up to the developer to tell the browser what your content is. And, if what you are sending down isn't in <a href="http://msdn.microsoft.com/en-gb/library/ie/gg622941(v=vs.85).aspx">IE’s allowable list</a> it is going refuse to execute your content, hence the blank areas of the screen. <br />If the "nosniff" directive is received on a response retrieved by a script reference, Internet Explorer will not load the "script" file unless the MIME type matches one of the values”. </p> <p>I also found the following <a href="http://htaccess.wordpress.com/2009/09/22/x-content-type-options-nosniff-header/">great article</a> written by <a href="http://htaccess.wordpress.com/author/htaccess/">Charles Torvalds</a>.</p> <p><b></b></p> <p><b>Next step, let’s try to fix our custom code…</b></p> <p>In the example SharePoint 2010 project which I developed for this blog post I had the following code in the Page_Load event of the custom page. This illustrates that when the page loads the code will retrieve the first item from the images library and render the image. </p> <p>protected void Page_Load(object sender, EventArgs e) <br />{ <br />    SPList imagelist = SPContext.Current.Web.Lists.TryGetList("Images"); <br />    if (imagelist != null) <br />    { <br />        SPFile oFile = imagelist.Items[0].File; <br />        byte[] img = oFile.OpenBinary(); <br />        Response.Clear(); <br />        Response.AddHeader("Content-Length", img.Length.ToString()); <br />        Response.ContentType = "application/octet-stream"; <br />        Response.BinaryWrite(img); <br />        Response.End(); <br />    } <br />}</p> <p>Note that the following line of code sets the response MIME type to “application/octet-stream”.  <font color="#0000ff">Response.ContentType = "application/octet-stream";</font></p> <p>The code worked fine in a SharePoint 2010 web application because in SharePoint 2010 there is no default X-Content-Type-Options response header with a “nosniff” value.</p> <p>I changed the code to rather specify a Mime type of “image/png” and I deployed it to my SharePoint 2013 web application and everything worked fine.</p> <p>protected void Page_Load(object sender, EventArgs e) <br />{ <br />    SPList imagelist = SPContext.Current.Web.Lists.TryGetList("Images"); <br />    if (imagelist != null) <br />    { <br />        SPFile oFile = imagelist.Items[0].File; <br />        byte[] img = oFile.OpenBinary(); <br />        Response.Clear(); <br />        Response.AddHeader("Content-Length", img.Length.ToString()); <br />        <font color="#ff0000">Response.ContentType = "image/png";</font> <br />        Response.BinaryWrite(img); <br />        Response.End(); <br />    } <br />}</p> <blockquote> <p><a href="http://lh3.ggpht.com/-GiuCF1As44g/Uic-T5WcNoI/AAAAAAAAAxU/nOBEiA16GV0/s1600-h/image%25255B8%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPkir01WUvZ_AvpgRIzjvn0rSrYbT1WIZsnYcNvDIskBi5LTCtTPlLy4-wiIYvqdcHdWrcECG2klqWn41zFKv28zDzBTOjO_mlKPmDPC9bzfIGd0YTnnKk7y58GLPV37RY0LjibWvSJkM/?imgmax=800" width="454" height="235" /></a></p> </blockquote> <p>This might be a very simple example of a potential serious challenge when you upgrade SharePoint 2007 or SharePoint 2010 solutions to SharePoint 2013. </p> <p>In his blog post Mark Jones also mention examples where he found Javascript with a MIME type of “<b>text/blank</b>” which should have been “<b>application/javascript</b>” and in other cases JSON which was sent down as “<b>application/json</b>” when it should have been “<b>application/javascript</b>”. I can only imagine that there are hundreds of similar cases.</p> <p>This might be a very simple example of a potential serious challenge when you upgrade SharePoint 2007 or SharePoint 2010 solutions to SharePoint 2013.</p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com3tag:blogger.com,1999:blog-429025622434259152.post-87012549914873913442013-03-16T12:21:00.001+02:002013-03-16T12:21:55.356+02:00Solved: The web being updated was changed by an external process.<p>Today I had to troubleshoot SharePoint site provisioning code which misbehaved on a particular server. It is always fun if code works well on a dozen SharePoint farms and then fails on one farm. <p>The code is a really simple C# console app which reads an xml file and it then uses the taxonomy specified in the xml file to create a SP web. <p>As part of the provisioning, the code will activate a set of standard SharePoint features and then activate the custom developed features. <p>I used the application on many different SharePoint 2010 farms to provision over 30 sites but recently we ran the tool on a new farm and we suddenly started getting the following error when the code tries to activate the SharePoint Publishing Web feature: <p><font color="#ff0000">Error: Provisioning did not succeed. Details: Failed to initialize some site properties for Web at Url: 'http://demo/Contoso' OriginalException: The web being updated was changed by an external process.</font> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSRhw7yAPTdbQa217V0QZ6Tr_-vlE3BpxbfTXLTMQALuISkPdWCyl8tFCn2E2S9crUQlSKgv8xx94W1ngaLqELzU6AxiyEg_ETG33qx3nxiWrlbZs27XJ6I4AMpbA9IwlZw_dUtVYZ1wE/s1600-h/clip_image001%25255B5%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://lh3.ggpht.com/-GzVmaK3LRE8/UURHsnQsvvI/AAAAAAAAAuI/FIb435zJsC4/clip_image001_thumb%25255B2%25255D.png?imgmax=800" width="604" height="74"></a> <p>This is the original code – before I made changes: <p><font color="#0000ff">Console.WriteLine("Creating a new web with title: " + webTitle);</font></p> <p><font color="#0000ff">site.AllowUnsafeUpdates = true;</font></p> <p><font color="#0000ff">SPWeb newweb = site.AllWebs.Add(webTitle, webTitle, webTitle, lcid, "STS#1", false, false);</font></p> <p><font color="#0000ff">site.AllowUnsafeUpdates = false;<br>Console.WriteLine("Web created. Ready to activate web features.");</font></p> <p><font color="#0000ff">if (newweb != null)<br>{<br> ActivateWebFeatures(newweb);<br>}<br>Console.WriteLine("Web created successfully");<br></font></p> <p>I discovered that the SPWeb newweb = site.AllWebs.Add( call actually returns the SPWeb object before all provisioning has been completed so the next time I try to update newweb I get the error “The web being updated was changed by an external process.” <p>In order to solve this I fetched the new updated instance of the SPWeb, so I added the following line of code: <font color="#ff0000">newweb = site.OpenWeb(webTitle); </font> <p>The following code works well: <p><font color="#0000ff">Console.WriteLine("Creating a new web with title: " + webTitle);</font></p> <p><font color="#0000ff">site.AllowUnsafeUpdates = true;</font></p> <p><font color="#0000ff">SPWeb newweb = site.AllWebs.Add(webTitle, webTitle, webTitle, lcid, "STS#1", false, false);</font></p> <p><font color="#0000ff">site.AllowUnsafeUpdates = false;</font></p> <p><font color="#0000ff">Console.WriteLine("Web created. Ready to activate web features.");</font></p> <p><font color="#0000ff">newweb = site.OpenWeb(webTitle); </font></p> <p><font color="#0000ff">if (newweb != null)<br>{<br> ActivateWebFeatures(newweb);<br>}</font></p> <p><font color="#0000ff">Console.WriteLine("Web created successfully");</font></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJAkjvRRcTE1xW48FHXdUvVVeCKd17oCIXDuJM49XUivzVRgsUKvv-1teTJj1F496u5e2oUt-bBW_Zzx95kWxcnF1PTI2zgL2PiM6a0FdveD73rSdEFDOi6C5JoA6fRyV40sgn5bFxnyw/s1600-h/image%25255B4%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmE0dLAzhClYEfmMVE1RtdRAFnro5KgneKi8_qpMnLtdDCzxrJP6x5gbplgKghjr_P_igIy4ulkezzNoboyY5AlSRdob_uZ1GLDQ0MMSBVwhxiOpFmzVzceYwZoUWXwsR_aDWh6JjwG1E/?imgmax=800" width="504" height="137"></a></p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com11tag:blogger.com,1999:blog-429025622434259152.post-679484154770007372013-03-06T20:31:00.001+02:002013-03-06T20:42:26.857+02:00Take Control: Programmatically verify SharePoint Managed Properties<p>This blog post is relevant to the following common search error: <p><i><font color="#ff0000">Property doesn't exist or is used in a manner inconsistent with schema settings.</font></i> <p>If you develop a custom SharePoint 2010 solution which consumes the FullTextSqlQuery class chances are good that after deployment to a new farm you will come across the following error: <p><font color="#ff0000">“Property doesn't exist or is used in a manner inconsistent with schema settings”</font> <p>This problem occurs when your source code tries to execute custom search queries against a Search Service implementation in which the crawled properties, managed properties or property mappings which your code is dependent on, are not configured correctly. <p>This blog post will show you how to programmatically take control of search dependant implementations and I provide a source code example which you can use to verify that the correct dependencies in place. <p>Imagine you developed a web part which allows a user to provide criteria and then search the site collection or specific webs (depending on search scope) to return a specific set of field values for each result item. <p>You have a document library: <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZKDE1bVo_WEvAfVMNmGUsb-CfSoe8aFTD5jSGWTvkNjKWoanCDoP9xv5q-jNXYDHdVtBIn7sogpJeQZ1r5EQDoUtlM7_Jx0svIJIDwpVZzEJ7tS_lMM0V5w6USN6fNAKz6iaUh5iTDJM/s1600-h/image21.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-A7ucNI5fq-I/UTeLXH2r0PI/AAAAAAAAAsQ/2A1BA7hh6xc/image_thumb7.png?imgmax=800" width="504" height="110"></a> <p>The search code looks like this: <p><font color="#0000ff">ResultType resultType = ResultType.RelevantResults;<br>string queryString = string.Empty;</font></p> <p><font color="#0000ff">try<br>{<br> FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(site);<br> fullTextSqlQuery.ResultTypes = resultType;<br> queryString = "SELECT <font color="#ff0000">Title,Division, Region, Language</font> FROM SCOPE() WHERE FREETEXT(*, '*test* ') AND (\"SCOPE\" = 'Demo Site Scope') AND (\"Division\" = 'Technical')";<br> <br> fullTextSqlQuery.QueryText = queryString;</font></p> <p><font color="#0000ff"> ResultTableCollection resultTableCollection = fullTextSqlQuery.Execute();<br> ResultTable resultTable = resultTableCollection[resultType];</font></p> <p><font color="#0000ff"> if (resultTable != null && resultTable.RowCount > 0)<br> {<br> while (resultTable.Read())<br> {<br> StringBuilder output = new StringBuilder();<br> output.Append("<font color="#ff0000">Title</font>:" + resultTable["<font color="#ff0000">TITLE</font>"].ToString());<br> output.Append(", <font color="#ff0000">Division</font>:" + resultTable["<font color="#ff0000">Division</font>"].ToString());<br> output.Append(", <font color="#ff0000">Region</font>:" + resultTable["<font color="#ff0000">Region</font>"].ToString());<br> output.Append(", <font color="#ff0000">Language</font>:" + resultTable["<font color="#ff0000">Language</font>"].ToString());<br> Console.WriteLine(output);<br> }<br> }<br>}<br>catch (Microsoft.Office.Server.Search.Query.QueryMalformedException querymalformedexception)<br>{<br> Console.WriteLine("Query syntax error: " + querymalformedexception.Message);<br>}<br>catch (Microsoft.Office.Server.Search.Query.ScopeNotFoundException searchscopeerror)<br>{<br> Console.WriteLine("Search scope error: " + searchscopeerror.Message);<br>}<br>catch (Microsoft.Office.Server.Search.Query.InvalidPropertyException invalidpropertyexception)<br>{<br> Console.WriteLine("Property error: " + invalidpropertyexception.Message);<br>}</font></p> <p>You test the solution on your development server and everything works well but after you deployed to a QA or production environment your custom search code throws an error: <p><i>Property doesn't exist or is used in a manner inconsistent with schema settings.</i> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhmZDj7GIj0OEDfqfqpzYTBACjIWJ7wwR2gOd_qfSi6tLfsAhrXYr1fqs6Wuew2RNA2ar4SAm99fH-3HGlMBY7Bv8Io2e8Z1blL2qVwi0ZLnGBNLXttc3882RZL7EfqLy7yJr0LzyYqjY/s1600-h/image23.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEfTIa9gJVzvsAWqFK7C54aUIQHE3YlAUmvkPinPDpU7m9HH3z-HM9-24WivIoFdGfBkeZC29x1CfIdpPfZbZaYWP5UVK4ip2Bvhi-LM3XYdfy5PpkGcKoIpl7eRcDbrPN6cd1wfcpPjs/?imgmax=800" width="504" height="37"></a> <p>The error does not contain information specific enough to help us identify which properties are not in place. <p>If you open SharePoint Central Admin –> Manage Service Applications –> Search Service Application –> Metadata Properties, we discover that some of the crawled properties which our search code rely on are not mapped to managed properties. In other cases some of the crawled properties do not even exist. <p>This is quite a common problem. Custom search code is dependent on specific configuration to be in place and there is always a risk during new deployments that either the provisioning code did not work properly or the SharePoint farm administrator did not configure the custom components correctly. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcbCdwZGtmG4gr8_9akTAdOJSNqTdxWHWe7xhEYz_DizHcwpbN5E9RHHO9Be9wGew2QZf2Pr6eiMzJVZBc56qPqEcs5LFPzcpUx1_Vfcrf7Ad2CfcUUW2o1ksKTHEsX7qgHw1p0JQgY-c/s1600-h/image24.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMTXWWFiOnm7LE7fPxJubgIE4eCbkZ5eR7cfupDYYCQ1eoYqnHNwgMKXtuXxpqZowI1u2jtam_oHdS9xofKOahcMHXdrsOHpprRtlnYPjD_jISTMA44K3g0Cn8g_RmYXeB_Q5eDn5SRJU/?imgmax=800" width="504" height="152"></a> <p>Obliviously we want to be SharePoint Heroes and see that our custom solutions works well after every new installation, so instead of relying on people or process let’s rather build a simple ‘success verification’ application which we can run on each new farm implementation to tell us whether all the dependencies are in place. <p>The source code from this post will generate the following output which will tell us exactly what the problem is: <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDDFjs9HVMCN8DKMDjDAyeOkkfyzyM3FWh-P3XHvyi2T6GFlljO0jg41Wq7u0NReFL_4HZz_rOfIf3fjvPVaE2TkPPg6oR3MZfDu_j8LdWbLszP49vkUNgA3c9wUe_f5VWdc7XvsK90Zk/s1600-h/image25.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwJxZlOLbmge_86bv_BnTv67Wb_PGrSAH8FCwYiaMznJHVaLONjwAuUtSAbEc2QOf_8b2Ban3Fb6jv4oyNlkA5UplIDF8CGn8MpT3t0R_WGk0DmoHKWOaS1RbcKY6xcd5fxclz79-jyto/?imgmax=800" width="504" height="135"></a> <p><b><font size="3">Validate Mapped Properties (command-line tool): </font></b> <p>This example was developed as a C# Console Application but you can use the code almost anywhere (perhaps a custom SharePoint configuration page is a good idea). <p>Add references to: <font color="#0000ff">Microsoft.Office.Server.Search and Microsoft.SharePoint </font> <p>Add the following using statements: <p><font color="#0000ff">using System;<br>using Microsoft.SharePoint;<br>using Microsoft.Office.Server.Search.Administration;<br>using Microsoft.Office.Server.Search.Query;<br>using Microsoft.Office.Server;<br>using System.Collections.Generic;<br>using System.Collections;<br>using System.Linq;<br>using System.Text;</font></p> <p>I developed a function called ValidateMappedProperties which takes two input parameters. The one input parameter is the SPSite and the other input parameter is a list of MetadataProperty objects. <p>The ValidateMappedProperties function will iterate through the list of MetadataProperty objects and for each item query the SP Search Service to check whether the crawled property, managed property and property mapping are in place. <p><b><font size="3">MetadataProperty class</font></b> <p>First let’s look at the MetadataProperty class. This class allows me to instantiate a new MetadataProperty object and set the expected properties. It is not necessary for you to create such a class but it does make it easier to manage the input- and result operations.</p> <p><font color="#0000ff">namespace ValidateMappedProperties<br>{<br> class MetadataProperty<br> {<br> public MetadataProperty()<br> {<br> this.PropertySet = Guid.Empty;<br> this.MappedPropertyName = String.Empty;<br> this.MappedPropertyType = 0;<br> this.CrawledPropertyName = String.Empty;<br> this.Verified = false;<br> this.VerifiedMessage = String.Empty;<br> }</font></p> <p><font color="#0000ff"> public MetadataProperty(Guid propertyset, string mappedpropertyname, Int32 mappedpropertytype, string crawledpropertyname)<br> {<br> this.PropertySet = propertyset;<br> this.MappedPropertyName = mappedpropertyname;<br> this.MappedPropertyType = mappedpropertytype;<br> this.CrawledPropertyName = crawledpropertyname;<br> this.Verified = false;<br> this.VerifiedMessage = String.Empty;<br> }</font></p> <p><font color="#0000ff"> public Guid PropertySet { get; set; }<br> public string MappedPropertyName { get; set; }<br> public Int32 MappedPropertyType { get; set; }<br> public string CrawledPropertyName { get; set; }<br> public bool Verified { get; set; }<br> public string VerifiedMessage { get; set; }</font></p> <p><font color="#0000ff"> }<br>}</font></p> <p><b><font size="3">ValidateMappedProperties function</font></b> <p>Now let’s consider the ValidateMappedProperties function. <p>This function will query the Search Service Application for a list of crawled properties and a list of managed properties. It will then loop through the list of supplied MetadataProperty items and verify whether all the dependencies are in place. <p><font color="#0000ff">public static void ValidateMappedProperties(SPSite site, List<MetadataProperty> managedproperties)<br>{<br> try<br> {<br> SPServiceContext serviceContext = SPServiceContext.GetContext(site);<br> SearchServiceApplicationProxy searchApplicationProxy = serviceContext.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;<br> SearchServiceApplicationInfo searchApplictionInfo = searchApplicationProxy.GetSearchServiceApplicationInfo();<br> SearchServiceApplication searchApplication = Microsoft.Office.Server.Search.Administration.SearchService.Service.SearchApplications.GetValue<SearchServiceApplication>(searchApplictionInfo.SearchServiceApplicationId);</font></p> <p><font color="#0000ff"> Schema sspSchema = new Schema(searchApplication);</font></p> <p><font color="#0000ff"> IEnumerable<CrawledProperty> _crawledProperties;<br> _crawledProperties = sspSchema.QueryCrawledProperties(string.Empty, 1000000, Guid.NewGuid(), string.Empty, true).Cast<CrawledProperty>();<br> ManagedPropertyCollection allprops = sspSchema.AllManagedProperties;</font></p> <p><font color="#0000ff"> foreach (MetadataProperty property in managedproperties)<br> {<br> property.Verified = true;<br> property.VerifiedMessage = "Success";</font></p> <p><font color="#0000ff"> var crawledProperty = _crawledProperties.FirstOrDefault(c => c.Name.Equals(property.CrawledPropertyName));<br> <br> if (crawledProperty == null)<br> {<br> property.Verified = false;<br> property.VerifiedMessage = "Crawled Property '" + property.CrawledPropertyName + "' does not exist.";<br> continue;<br> }</font></p> <p><font color="#0000ff"> if (!allprops.Contains(property.MappedPropertyName))<br> {<br> property.Verified = false;<br> property.VerifiedMessage = "Managed Property '" + property.MappedPropertyName + "' does not exist.";<br> continue;<br> }</font></p> <p><font color="#0000ff"> try<br> {<br> bool hasmapping = false;<br> ManagedProperty mp;<br> mp = sspSchema.AllManagedProperties[property.MappedPropertyName];</font></p> <p><font color="#0000ff"> List<CrawledProperty> mappedcrawledproperties = mp.GetMappedCrawledProperties(1000);<br> foreach (CrawledProperty item in mappedcrawledproperties)<br> {<br> if (item.Name == property.CrawledPropertyName)<br> {<br> hasmapping = true;<br> continue;<br> }<br> }</font></p> <p><font color="#0000ff"> if (!hasmapping)<br> {<br> property.Verified = false;<br> property.VerifiedMessage = property.MappedPropertyName + " is not mapped to crawled property '" + property.CrawledPropertyName + "'.";<br> continue;<br> }<br> }<br> catch<br> {<br> }<br> }<br> }<br> catch (Exception ex)<br> {<br> Console.WriteLine("Error: " + ex.Message);<br> }<br>}</font></p> <p><b><font size="3">Request Method:</font></b> <p>And, lastly the following code will illustrate how to define the list of expected MetadataProperty settings then call the ValidateMappedProperties function and then write the results to a console window: <p><font color="#0000ff">static void Main(string[] args)<br>{<br> string siteURL = args[0];</font></p> <p><font color="#0000ff"> List<MetadataProperty> managedproperties = new List<MetadataProperty>();<br> Guid guidPropset = new Guid("00130329-0000-0130-c000-000000131346"); //this is the SharePoint columns propertyset ID. <br> <br> managedproperties.Add(new MetadataProperty(guidPropset, "Division", 31, "ows_Division"));<br> managedproperties.Add(new MetadataProperty(guidPropset, "Region", 31, "ows_Region"));<br> managedproperties.Add(new MetadataProperty(guidPropset, "Language", 31, "ows_ContentLanguage"));<br> <br> using(SPSite site = new SPSite(siteURL))<br> {<br> ValidateMappedProperties(site,managedproperties);<br> <br> foreach (MetadataProperty item in managedproperties)<br> {<br> if (item.Verified)<br> {<br> Console.WriteLine("Succcess : " + item.MappedPropertyName);<br> }<br> else<br> {<br> Console.WriteLine("Failed : " + item.VerifiedMessage);<br> }<br> }<br> }<br> Console.WriteLine("");<br> Console.WriteLine("Operation completed. Press any key to contine...");<br> Console.ReadKey();<br>}</font></p> <p>The result will tell us where the problem lies:</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXIaxj_ijxmbg-_ujsN732DDSc9jIlHTV8bqezEblma4Qf2B7iTFrH3NYlQZoMjbPmesbHUQzyqYXL0KzLrGDTj1iGPDTEK55ns-49ZcuwQAFg3sCqvYjR0AhuX_SU9xW7G__Q-zVj_Jg/s1600-h/image26.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8wQxQwnyN8iJr5cjO8QUlZsfEKtXek8KRiG9oDbjnF3NyKxyPsrQyYFd8239dPIQRAEvU23Poy8jt_ISgG0edGt6mmft0H6MDmwgiqBdOrMtBZFQSb3605NBZbkuUjE4BOOCAAS4BwFo/?imgmax=800" width="504" height="135"></a></p> <p>I can now use this information to make the necessary changes in Central Admin and run the tool again. I can repeat this process until I get success on all items:</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNwusC1Bcww4pMiJcl-U2EoNpIjf_HPKOZrOQoEX2W9pDG_rU6K-c8OyWd_EgsIoNJcXyxxGxz8wC9khAM076n6xGx9ZyTjF1VHtlNge_iYvtdxDVotGzpe9_kOBjWDFmfoqwvDmt4zkU/s1600-h/image27.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb7gVNv-vHD1-5iLGJsKov81Z5lLJ-TEmA-qz3o77w9PoRZrfJXDwroZB1R5qcyjnbbOTghWP520XC91l_yvsd-edLA_fhrmmPaDbB-BBvhm6gw0iLBaB3s3S_xXdJ4IzkuQwp6jIqjqE/?imgmax=800" width="504" height="119"></a></p> <p>Now that I know all the dependencies are in place I am certain that, my custom search solution will work. <p>The screenshot below shows the results produced by running the example search code: <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtk-nNlbHp9shVKLmCrzvjaUPd2GzLIBK9z_LyywV67oEN_R6bM3ELrRU09SgS1lykhQObpK4G2Auk09vHqusdyKiPTbHyj60H-8pWKUkphcUaH_mUEfSm5vobVlLlnyPs5jwRVwi9Uek/s1600-h/image28.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAKqAOqBKS-Mrs-ngYNWjwuw-ii5ScJSEyjNfP2sQwAlEA_YQLYzWfUH-hoc6HRjeR9bhfc6sk4Bd8wZHNokHl8KXtR-nkcptS8-oEuC4LGHUTglQ_QtyQ_bv7-m7Uy6MemOZVfyYjUxI/?imgmax=800" width="504" height="96"></a> <p>Enjoy!! Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com3tag:blogger.com,1999:blog-429025622434259152.post-54539841402991897952013-03-05T09:05:00.001+02:002013-03-05T09:14:48.675+02:00A Better way to attach custom SP2010 event receivers<p>I recently decided to take a deeper look into code which is used to programmatically attach or remove a SharePoint event receiver against a SharePoint list. <p>Using the SharePoint 2010 Object Model to programmatically add or remove an event receiver is really simple….and that is exactly the problem I came across. As developers we sometimes tend to have a ‘<i>get the job done</i>’ attitude and we do exactly that…we write code which executes without any problems and which delivers the expected results, so we consider the job done and we move on. If we want to build robust code we have to consider the different syntax options and implement what we believe is most relevant in the particular scenario. <p>So I took the C# code and made slight changes to it and now I get much better (and more granular) control. I am now able to programmatically set the SharePoint custom event receiver properties. <p>Scenario: I have a SharePoint 2010 site which contains a number of custom event receivers. These event receivers can be web scoped, site scoped, or list scoped (this example). Based on a specific action (trigger) I want to programmatically attach or remove the custom event receivers to / from their target. Examples of triggers are: a business rule (workflow), a custom page code behind (like a settings page), provisioning logic, etc. So, the code which manages the event receivers can live almost anywhere. In this example I make use of a custom provisioning feature to manage the event receivers. In other words if my custom provisioning feature is activated it will attach my custom event receivers and when the feature is deactivated it will remove the event receivers. <p>This is the old code before I made changes: <p>public override void FeatureActivated(SPFeatureReceiverProperties properties)<br>{<br> using (SPWeb web = properties.Feature.Parent as SPWeb)<br> {<br> SPList list = web.Lists.TryGetList("test");<br> if (list != null)<br> {<br> string classname = "SharePointDemoCode.Custom.EventReceivers.SetDealValuesReceiver";<br> string assembly = "SharePointDemoCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1ee7eff4c43a8776";<br> web.AllowUnsafeUpdates = true;<br> list.EventReceivers.Add(SPEventReceiverType.ItemAdded, assembly, classname);<br> web.AllowUnsafeUpdates = false;<br> }<br> }<br>}</p> <p>This code will attach the event receiver without any problems but if I use SharePointEventReceiverManager.exe to analyse the event receiver association I can see that the event sequence number set to 10000 (default value) and the event receiver name is empty. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnV4psRrXzSBpTEAGY5rue_uq7al37RVWKOOZCrfakfbJN1eOftJnzGythYCet0DDYEHmGsh0KSP53oBL8-2-x5UVL5ACVNxc69-fPV7nk6pnT7kYQBR1__gjqg0gQPuru5iIK1PUwGIs/s1600-h/image%25255B3%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZGrOxtuE_Oy_iJzu3ev887-eW2mjX_RxCbS0QbfciAMlRxUR3k7bRuX6apnr75_fHpo1NC2GT8qnZ54wzHofQpoc48REHu4nRMF33KU1fMscI7Kg_z3xo0SzzJn92_oq9gSDyKYJWaJw/?imgmax=800" width="504" height="316"></a> <p>So to have control over the above mentioned properties one can rather use the following code: <p>public override void FeatureActivated(SPFeatureReceiverProperties properties)<br>{<br> using (SPWeb web = properties.Feature.Parent as SPWeb)<br> {<br> SPList list = web.Lists.TryGetList("test");<br> if (list != null)<br> {<br> string classname = "SharePointDemoCode.Custom.EventReceivers.SetDealValuesReceiver";<br> string assembly = "SharePointDemoCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1ee7eff4c43a8776";</p> <p> SPEventReceiverDefinitionCollection eventReceivers = list.EventReceivers;<br> SPEventReceiverDefinition neweventReceiver = eventReceivers.Add();<br> neweventReceiver.Name = "Set Deal Values Receiver";<br> neweventReceiver.Synchronization = SPEventReceiverSynchronization.Default;<br> neweventReceiver.Type = SPEventReceiverType.ItemAdded;<br> neweventReceiver.SequenceNumber = 25001;<br> neweventReceiver.Assembly = assembly;<br> neweventReceiver.Class = classname;<br> neweventReceiver.Update();<br> }<br> }<br>}</p> <p>From the image below you can see that the event sequence number set to 25001 and the event receiver name is ‘Set Deal Values Receiver’ – this is exactly what I wanted to have control over. </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg42dLLhu_zJ88BY2rPM29aQ-s97T2npVBq5DR6F7RIipzUBC3drRIILzmtn2bSP4z1Fi3UR8VFVorbynJoIe1M7640OcUzsRvXqodyEAMCXnXKwAZ7iwiqdiklzdFHOVm76FbWRzHDRYM/s1600-h/image%25255B7%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqqCi9prboxrcLW9S3MBAP9VLuVv6JF_vGnlzT2ZVJ6choNYdSFyPg_KsrkZBczG3xwFZscDLk9vA4T7laIDr1gnyMQAvd-9h0zQg-TFF3fHEdOcKy1prMIJjQvDsQwuSqMEldBTiYdyk/?imgmax=800" width="504" height="300"></a></p> <p>To remove / detach an event receiver use the following code: <p>public override void FeatureDeactivating(SPFeatureReceiverProperties properties)<br>{<br> string classname = "SharePointDemoCode.Custom.EventReceivers.SetDealValuesReceiver";</p> <p> using (SPWeb web = properties.Feature.Parent as SPWeb)<br> {<br> SPList list = web.Lists.TryGetList("test");<br> if (list != null)<br> {<br> IEnumerable<SPEventReceiverDefinition> eventReceiverResults = list.EventReceivers.Cast<SPEventReceiverDefinition>().Where(receiver => string.Equals(receiver.Class, classname, StringComparison.OrdinalIgnoreCase));</p> <p> if (eventReceiverResults.Any())<br> {<br> foreach (SPEventReceiverDefinition eventReceiver in eventReceiverResults.ToList())<br> {<br> list.EventReceivers[eventReceiver.Id].Delete();<br> }<br> }<br> }<br> }<br>}</p> <p>For a complete list of SPEventReceiverDefinition Members go to: <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverdefinition_members(v=office.14).aspx">http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverdefinition_members(v=office.14).aspx</a> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com4tag:blogger.com,1999:blog-429025622434259152.post-69342907424149192942013-02-13T17:22:00.001+02:002013-02-13T17:30:17.298+02:00Field with name … was not found - SPFieldCollection<p>A booby trap is a device or setup that is intended to kill, harm or surprise a person, unknowingly triggered by the presence or actions of the victim. <p>The SharePoint 2010 Object Model has a couple of ‘booby traps’ and if you don’t pay careful attention you might end up wasting precious time trying to troubleshoot code which should be working. <p>The following issue is a classic example of syntax which is really easy to implement and descriptive enough to prevent us from making mistakes…but it can be a little misleading. <p>If you want to retrieve an existing site column (field) from a SPWeb and you know what the internal name of the field is you can use the following to get the field: <p>SPField newField = web.Fields.GetField(fieldname); <p>If you don’t know the internal name of the field but you know what the display name of the field is you can use the following to get the field: <p>SPField newField = web.Fields.GetField(fieldname); <p>or <p>SPField newField = web.Fields[fieldname]; <p>Now, imagine you want to programmatically (C#) add a site column (field) to a SharePoint list, library or content type. <p>First you want to check if the field exists, then you want to retrieve the field and finally you want to add the field to a list, library or content type. <p>1-You can use the display name of the field to check if it exists: <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Le4Gub_2M7Ejc6qbRPTzirGHUqeU_slDYgFwUoOBY0deesQkkQIJ2ybv_7aqbuIVeWvD8VKQnvBR_VqPwuLupQxYOkQdagzN_fx4UQYzqYXMnUZqn98K746y1CeS77tSMF8o5TVGdes/s1600-h/image%25255B15%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEqM_Fvy3lMGJBBJStEV-q8yOM8UPS6U319CNaklqkShizDlBWxwPL-MBPbNzLFHLZtAlOIzEp3cq7Kj6IwdJtOnhpgOyG40loErAW-SEhDdUBFm4KspJbfmUhCrzwELUQ8xiiBrOWMaU/?imgmax=800" width="484" height="84"></a> <p>The result is = true so <p>2-You want to use the display name of the field to fetch the field from the web: <p><a href="http://lh6.ggpht.com/-8U1gA6hg4Po/URuvvxoXdgI/AAAAAAAAAqY/4AODwYR9Jho/s1600-h/image%25255B16%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrd2-YedW2SOJ3Wi2V8jsNWNzYiHz9L-_XyHnnRnHTvTqlOWRMauuV4pPQZj6D41k_M_2RYylPw09y36FS0Fup0Itps5Kn5Do6qoOWpFqxqa3A9dvdIPeDFuliX86lRfEiJIpCoC1MlpI/?imgmax=800" width="484" height="62"></a> <p>You can see from the two screenshots (above) that the comments indicate that the ‘display name’ can be used in both functions so by looking at it one would assume that if web.Fields.ContainsField(“SolutionExpert”) is true then you will be able to retrieve the field by using SPField newfield = web.Fields[“SolutionExpert”] ... but there is a problem!!! <p>The internal name of my field is ‘SolutionExpert’ and the display name is ‘Solution Expert’ so I made a mistake!! <p>If you look closely at web.Fields.ContainsField(string fieldName) you will see that the method accepts <b>either</b> the display name or the internal name of the field, so you might find yourself in a situation where you passed in the internal name of a field to web.Fields.ContainsField and the result was true, but when you then use the same field name to try access the field with newfield = web.Fields[fieldname] you will get an error because newfield = web.Fields[fieldname] only accepts the display name of the field and not the internal name. <p>Example: <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8VJs4CvBGKTA1seraYjWq-QOfRhcXZKEKHFFK4mzCm5Fbp4U0iECRPjS51Pt4KuJWZlULUn0CHpaueb3bdwC6fvvX-RMUctzxciCV1lvbbnWkkCgyb_GDERmMWLNHULilB4k04_6QHAE/s1600-h/image%25255B18%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-Ggle2HiElJM/URuvyTukH-I/AAAAAAAAArM/PyKhWbfIRXg/image_thumb%25255B10%25255D.png?imgmax=800" width="554" height="158"></a></p> <p>So, remember that it is much safer to reference fields by its internal name and instead of using </p> <p>SPField newField = web.Fields[fieldname] <p>rather use: <p>SPField newField = web.Fields.GetField(fieldname); <p><a href="http://lh4.ggpht.com/-pX84irMFzh8/URuvzB9MqjI/AAAAAAAAArQ/kE3T6qFQv0A/s1600-h/image%25255B19%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqgSlyQQUJ3FdsrZw9n679_89E-sYMzeJQumjYtcbyvpa62rK_z9f5Dg1JZkec_ORWsVP7-tOiDCX1gkMBtwQpw4In4ix909C6Db9SMGD4KEXOS-hxk6avMnnCPVYGaYH5bP1F6xhFMKs/?imgmax=800" width="554" height="210"></a> <p>Also see: http://msdn.microsoft.com/en-us/library/ms196070.aspx Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com3tag:blogger.com,1999:blog-429025622434259152.post-77241184887382054062013-02-11T17:33:00.001+02:002013-02-11T17:45:17.980+02:00Get / Set field order for SharePoint 2010 list or library<p>When you build custom SharePoint solutions there are times when you need to create lists/libraries and fields (site columns or list fields) during run-time. </p> <p>Using the SharePoint 2010 object model to programmatically create site columns, content types or list and library fields is really easy but you will find that the order in which the new fields appear on the item's view- and edit forms depends on the execution order of the code which provisioned the fields. <p>To illustrate this, imagine you have a document library called ‘Technology’ which contains 2 fields called ‘Name’ and ‘Title’. <p>An event triggers your code to add 2 new fields to the document library. First the code adds the field ‘Product’ to the library and then the code adds the field ‘Document Summary’ to the library. At this point your library will contain 4 fields in the following order: 1-Name, 2-Title, 3-Product, 4-Document Summary. <p>Later another event triggers your code to add a field called ‘Product Version’ to the same library. The result will be that the new field will be displayed in position 5 on the view and edit forms. This is not ideal – as you can see from the image below, the position of the ‘Document Summary’ field should rather be below ‘Product Version’. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjMev52c5RXRrB8yT7dcxKgLHppzaUQTFAOSYF4J3DJrwBNMUegxNJuRiaNPC0y7S6XbTr4HE0_12zzvGCqdhEpvV1rgDGOW3Hi0YHK-jMXGqZ3dzp9VBk0D0rc8ueEC2DJPJFBrmSqoY/s1600-h/image%25255B46%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhB2Z0-JcWg1Xy6CeMjLRRXKAEt3f2TI3gACHwZG4mh7dR3qz614cSejEfwAJg-dVerSasBjOgNJjffzh2s61j27zUQFn4S9oMoYv5-GFtP-YPl06zXOAcoPPFQUeWcRSRrNUbSw6L4N74/?imgmax=800" width="404" height="232"></a> <p>Fortunately there is an easy way to programmatically control the order in which fields appear on the list item view- and edit forms. <p>Many thanks to Rahul Sharma for his original post on this topic – I used the basics from his post <a href="http://www.directsharepoint.com/2011/11/change-column-order-in-new-and-edit.html">http://www.directsharepoint.com/2011/11/change-column-order-in-new-and-edit.html</a> and extended it to fit my needs. <p>The following code illustrates three functions: <ol> <li>Get the display order of all visible fields for a specified list/library <li>Get the display order of a specific list of fields for a specified list/library <li>Set the display order of a specific list of fields on a list/library item’ view- and edit forms.</li></ol> <p>(The code is written in a simple console app. Remember to add a reference to Microsoft.SharePoint.dll and change your console app platform target to 64bit – and add proper exception management) <p><strong><font size="3">1-Get the display order of all visible fields for a specified list/library</font></strong></p> <p>Based on the scenario described above the result from the code below is:</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWcH_dw5RUMXYXCurwenCzYsnpDI5K3bCTGN3xpDjtk9GTiv3IXr7cRpXDQZN_UwOpndFy9Ea-lMq8qUyKelrGoxtdzq_i0FA7hQ__0WQZ-ZILyekQ6xL3YB-mLGOy3CkBpQwwZefLiC4/s1600-h/image%25255B65%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhP3WBTOeM2LuGOawY1eRqAU7b2_LQ74vYjPZ4uU2GimzJ8YjBQy4cz65oNy9nujTk5gpkM0oUa7CxN5dS_9Erqhbi5lEJbuzs9YYuX2DhyTvL4leIIr2ck4W0L7dg7dsj_pIbQhGinsRI/?imgmax=800" width="238" height="112"></a></p> <p>static void Main(string[] args)<br>{<br> using (SPSite site = new SPSite(args[0]))<br> {<br> Dictionary<string, int> actualfieldsorder = FetchFieldOrder(site.OpenWeb(), "Technology", "Document");<br> <br> foreach (KeyValuePair<string, int> pair in actualfieldsorder)<br> {<br> Console.WriteLine(pair.Key + " : " + pair.Value);<br> }</p> <p> Console.WriteLine("");<br> Console.WriteLine("Done");<br> Console.ReadKey();<br> }<br>}</p> <p>private static Dictionary<string, int> FetchFieldOrder(SPWeb web, string listname, string contenttypename)<br>{<br> Dictionary<string, int> fieldsorder = new Dictionary<string, int>();<br> SPList list = web.Lists.TryGetList(listname);<br> if (list != null)<br> {<br> SPContentType spct = list.ContentTypes[contenttypename];<br> int positionindex = 0;<br> foreach (SPField field in spct.Fields)<br> {<br> if (!field.Hidden && field.Reorderable)<br> {<br> if (field.ShowInEditForm == null)<br> {<br> positionindex++;<br> fieldsorder.Add(field.InternalName, positionindex);<br> }<br> else<br> {<br> if ((bool)field.ShowInEditForm)<br> {<br> positionindex++;<br> fieldsorder.Add(field.InternalName, positionindex);<br> }<br> }<br> }<br> }<br> }</p> <p> return fieldsorder;<br>}</p> <p><font size="3"><strong>2-Get the display order of a specific list of fields for a specified list/library</strong></font></p> <p><font size="3"><font size="2">There might also be situations whereby you want to determine the display order for a specific list of fields in relation to each other. </font></font>Example, I want to determine whether the ‘Product’ field will appear above the ‘Product Version’ field. I am not interested in any of the other fields.</p> <p>The code below will return the following result:</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVyoYCRvXMlDbHypH4kJ-WDbynrfa9gcFDF0Y8CI3rSyciXAplmlq_yAWuLtfQczSA3TaS9thG-ZuMH-NAz56FypmoGLS9n6wwOToVb-631Hab_Vx-4wMCIEuwtLxuMyzsiB5q9mgdIvA/s1600-h/image%25255B32%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEic28ZWwRAY7XtBR_VsDZtMNVNEu_Rc6FtQ92WLfGeD1mwhF22qOtjKOHiEbo5W-8tC-Fic3b3GeNg8pRyfg_0dLnpolRvcVXEx_v3qiBEF4mEyvXgUjDfysIdFZ05HnkrEnWcL48eSG4Q/?imgmax=800" width="244" height="82"></a></p> <p>static void Main(string[] args)<br> {<br> using (SPSite site = new SPSite(args[0]))<br> {<br> List<string> fields = new List<string>();<br> fields.Add("Product");<br> fields.Add("Product_x0020_Version");<br> Dictionary<string, int> actualfieldsorder = FetchFieldOrder(site.OpenWeb(), "Technology", "Document",fields);</p> <p> foreach (KeyValuePair<string, int> pair in actualfieldsorder)<br> {<br> Console.WriteLine(pair.Key + " : " + pair.Value);<br> }</p> <p> Console.WriteLine("");<br> Console.WriteLine("Done");<br> Console.ReadKey();<br> }<br> }</p> <p>private static Dictionary<string, int> FetchFieldOrder(SPWeb web, string listname, string contenttypename, List<string> checkfields)<br>{<br> Dictionary<string, int> fieldsorder = new Dictionary<string, int>();<br> foreach (string fieldname in checkfields)<br> {<br> fieldsorder.Add(fieldname, 0);<br> }<br> SPList list = web.Lists.TryGetList(listname);<br> if (list != null)<br> {<br> SPContentType spct = list.ContentTypes[contenttypename];<br> int positionindex = 0;<br> foreach (SPField field in spct.Fields)<br> {<br> if (!field.Hidden && field.Reorderable)<br> {<br> if (field.ShowInEditForm == null)<br> {<br> if (fieldsorder.ContainsKey(field.InternalName))<br> {<br> positionindex++;<br> fieldsorder[field.InternalName] = positionindex;<br> }<br> }<br> else<br> {<br> if ((bool)field.ShowInEditForm)<br> {<br> if (fieldsorder.ContainsKey(field.InternalName))<br> {<br> positionindex++;<br> fieldsorder[field.InternalName] = positionindex;<br> }<br> }<br> }<br> }<br> }<br> }</p> <p> return fieldsorder;<br>}</p> <p><strong><font size="3">3-Set the display order of a specific list of fields on a list/library item’ view- and edit forms</font></strong></p> <p>The following code will set the display order of the specified fields. Please note that the parameter ‘CustomOrder’ contains the fields which you want to reorder. The order in which the fields will appear on the view and edit forms is determined by the order in which you programmatically add the fields to the List variable '(CustomOrder). If you want you can change to code to have even more granular control. </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoTBOGGVXxyf9s5CXMPWR8SIHY_YklKjlMpcmsOX1evR7vLQeCP8DvAHbfWfF_QN7qAWBpXRyXS7ExUUBGHfl7TWKPm7oTZB5w9LU9Ol4Dno3WNWOlrBnANNLWYLIHuSyS2BMUmJ8-2Cg/s1600-h/image%25255B41%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOAODU6ZGzkYuAjNB9S8oegip1WnQvrdezmiknlD5-LXJ4uwL103AMR6MN4NgRRjOCRgxl01qFFsPG_iO-XppHdZEOx1MsFQQ-XNx4fMhnzwXxGtofkPOg487oOk4Lk_8gfQd7MmctK1w/?imgmax=800" width="504" height="144"></a></p> <p>The code below will result in the following:</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj20yBJ-i6_Udjvi_QubVKAls_R15AsoxS86v71O_Dl_xbY1w18fXMyHPx_vTYnSI4-cUbS8asHkUGo-z708exoMywUakW-LeI3-HOt-pDTj8rCQpGfdUwiOcGFq403_ee9OVGv1-0v7xE/s1600-h/image%25255B59%25255D.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgclHuj3VuA9u8ZqUqx_Cd7fLhlEj8loSmm3Mo9OdnWYk670qf-30VkTkpo5pbpibjrcQUPHlEdl84YeWF-cKJmaHVBMkyEQ2SBpCDaBqHcvByVYjWXIw1_D3oOoQU3EjB9jXJmMAPPv4E/?imgmax=800" width="504" height="171"></a></p> <p>static void Main(string[] args)<br> {<br> using (SPSite site = new SPSite(args[0]))<br> {<br> List<string> CustomOrder = new List<string>();<br> CustomOrder.Add("FileLeafRef");<br> CustomOrder.Add("Title");<br> CustomOrder.Add("Product");<br> CustomOrder.Add("Product_x0020_Version");<br> CustomOrder.Add("DocumentSummary");</p> <p> SetFieldOrder(site.OpenWeb(), "Technology", "Document", CustomOrder);</p> <p> Console.WriteLine("");<br> Console.WriteLine("Done");<br> Console.ReadKey();<br> }<br> <br> }<br></p> <p>private static void SetFieldOrder(SPWeb web, string listname, string contenttypename, List<String> CustomOrder)<br>{<br> try<br> {<br> SPList list = web.Lists.TryGetList(listname);<br> if(list!=null)<br> {<br> Dictionary<Int32, String> listColumnReorder = new Dictionary<Int32, String>();<br> int iCounter = 0;<br> foreach (string item in CustomOrder)<br> {<br> if (list.Fields.ContainsField(item))<br> {<br> SPField field = list.Fields.GetFieldByInternalName(item);<br> if (field != null)<br> {<br> if (!field.Hidden && field.Reorderable)<br> {<br> if (field.ShowInEditForm == null || (bool)field.ShowInEditForm)<br> {<br> listColumnReorder.Add(iCounter, field.InternalName);<br> iCounter++;<br> }<br> }<br> }<br> }<br> }<br> String[] sFields = new String[listColumnReorder.Count];<br> foreach (Int32 order in listColumnReorder.Keys)<br> {<br> sFields[order] = listColumnReorder[order];<br> }<br> ReOrderColumn(sFields, list.ContentTypes[contenttypename]);<br> }<br> }<br> catch (Exception ex)<br> {<br> // add your own exception management here...<br> }<br>}</p> <p>private static void ReOrderColumn(String[] fieldInternalNameArray, SPContentType objContentType)<br> {<br> try<br> {<br> SPFieldLinkCollection fldLinks = objContentType.FieldLinks;<br> fldLinks.Reorder(fieldInternalNameArray);</p> <p> objContentType.Update();<br> }<br> catch (Exception ex)<br> {<br> // add your own exception management here...<br> }<br> }</p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com1tag:blogger.com,1999:blog-429025622434259152.post-38042297962847001232011-12-06T15:03:00.001+02:002011-12-06T15:27:59.546+02:00Show or Hide SharePoint Ribbon Tab based on User Permissions<p class="MsoNormal">This week I wanted to figure out how to show or hide a custom developed SharePoint Ribbon Tab based on the permissions of a logged in SharePoint user. <?xml:namespace prefix = o /><o:p></o:p></p> <p class="MsoNormal">I have a custom SharePoint 2010 Ribbon Tab with the title ‘Show or Hide Tab’ and I want to hide the tab if a current logged in user is a member of the ‘Root Visitors’ security group. <o:p></o:p></p> <p class="MsoNormal">I do not want to hide the entire ribbon and I also do not want to hide only the inactive buttons. The ribbon with the ‘Documents’ and ‘Library’ tabs must be visible for all users and audience targeting must be applied to the new custom ribbon tab.<o:p></o:p></p> <p class="MsoNormal">I can imagine that the requirement is quite a common one. You might want to develop a set of custom tabs which are only visible to users who are members of a specific SharePoint group.<o:p></o:p></p> <p class="MsoNormal">I assume that you know how to develop a custom ribbon – if not please follow the great blog series by Chris O’Brien on <a href="http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html">Ribbon Customizations</a> and ensure that your custom ribbon tab works before you continue with this tutorial.<o:p></o:p></p> <p class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6vnUaOsdZx2MrieY4pFKMGjnTr-36Em6t4JIJ5X87yF7qiasw5iYJUC5ESgsiYumOAyE-m70T1eQp7eMS2baJNAe3PvixTafXVb-t5sY42FEANVW-GcoPYbR4MAXpSMMJy1QFQMYgWOQ/s1600-h/clip_image001%25255B14%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001" border="0" alt="clip_image001" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSGbAGgKCsA2QwQE8xfLVcY_T0P5wJsi0y1FZuuQRRQGI62n94UtqwB5d2WGj54_U77s5dsElTDK02ygnPutaBkNhniQtuklkAbJK3z0Pjv2KmlG63VLzLhH6KPhFYPaSZCTbBW5fGRRk/?imgmax=800" width="368" height="132" v:shapes="Picture_x0020_1"></a></span><o:p></o:p></p> <p class="MsoNormal">I could not find a blog with an appropriate example on the web so I used a combination of a few blog posts and added my own logic.<o:p></o:p></p> <p class="MsoNormal">I want to thank Chris O’Brien for his series on <a href="http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html">Ribbon Customizations</a> and Tobias Lekman for his <a href="http://blog.lekman.com/2011/05/hiding-inactive-ribbon-commands-in.html">helpful blog post</a> . Their contributions were extremely helpful during my research.<o:p></o:p></p> <p class="MsoNormal"><b style="mso-bidi-font-weight: normal"><font size="3">How it works:<o:p></o:p></font></b></p> <p align="left">I have a custom ribbon with the title ‘Show or Hide Tab’.I also have a SharePoint Group Called ‘Root Visitors’. I log in to SharePoint as a user who is not a member of this group.<o:p></o:p></p> <p class="MsoNormal"><b style="mso-bidi-font-weight: normal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJCd8HUsrkrYRz6eRKh8STykjAX-xP5sRxhKofRtX8iGAQUofgBYFS6ZZJzYnEofIlRO2kWr-BzDTEKMTw6Tovu-SxfkCi51bJ36lF_tq2b5pLEkFYEzUSG-HZ3optNia1RfdzlnGogQc/s1600-h/clip_image002%25255B12%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyuoWbNpETNoXFZlon3RPHCvYDETcA-l9h6HoEgfsOM2lSchZDVqP3q7m5xdJ9tx30cehqTbxX4Jb-4VdSQTKe0wLBC67iOPZAIwlQaJ12SZrnrZQ7AcGORk7j2P99cbm6vRnllC_hvNo/?imgmax=800" width="368" height="140" v:shapes="Picture_x0020_2"></a></span><o:p></o:p></b></p> <p class="MsoNormal">I navigate to the Shared Documents library and do not see the custom ribbon tab.<o:p></o:p></p> <p class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQ6CwnwOAXFbO6XuZI8mFQEP4oyGirLUSfdQ50_OqlcKC7OmkAVPbAeZ2YnPByBlwBotRT5vEoLv_Mv80EBSzLIflqvZ1-BMF_TjucJDCSy2OnzYZ9uBeUahrr-pbJRaGWUthhcTUQjhM/s1600-h/clip_image003%25255B22%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image003" border="0" alt="clip_image003" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiur0r2D45HrZdc4lN4z8fpBhjcYkBeC-_pWOCB1gDWlvSL9c8ynniJeiKgk3rEMLkgz9JvNNeaQWS8joxjuMD9Ox2y4q7znW51HD9IwJkxWTWXEfIqONBdIn0iJh30EVk8pMOXv21XW7U/?imgmax=800" width="368" height="86" v:shapes="Picture_x0020_6"></a></span><br style="page-break-before: always; mso-special-character: line-break" clear="all"><o:p></o:p></p> <p class="MsoNormal">Now I add the user to the security group<o:p></o:p></p> <p class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgktUuk6D5VHbq91y8ZfEsmDTom-jQ63MQTOCeZ0F4cqCMkaMpYH9p40U2grP39rWQZ6IWkpmd7m09VyAccAfwXGbiPduVEUoY024x3XszR7kC_-9i0509pIyulbnWk2ON3c8U5CB79i_Q/s1600-h/clip_image004%25255B11%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image004" border="0" alt="clip_image004" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiO0BhY68pqyVtBDLALBH4rJC_mbC4GvevQCf_QsMZhqyCOFsp1kjBJibJxUh7gHywnGvJ_jObtI3KVQu6hW-har4_iWAQvjNa4no5ZCKAc2aOce1yIxZwpFD1P5mQ2EhZqgOJY1dY_Wvw/?imgmax=800" width="368" height="127" v:shapes="Picture_x0020_4"></a></span><o:p></o:p></p> <p class="MsoNormal"><o:p> </o:p>…and I navigate back to the Shared Documents library. Now the custom ribbon tab is visible.<o:p></o:p></p> <p class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikaQ92GXLHIAZd34nAOUYkE5w350hFTFJrrs8tVHfrScbh19maKksKfHhN4d6MTNUKv5LTpFF7mxFNjB2ueHihIl4UGKLAj2JZLeG5HMPTeL34HgYaqRnDRPSVVovjj2o3b8IQhAs_JCY/s1600-h/clip_image005%25255B22%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image005" border="0" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-FAY0dcnkborQjOx464Uk2OunSViWrISesBbpBSRljv0hivk5j8bYfoICHogrZ5OIKkOFVm-brTN0GLFd2y0RXUSdXlqAVjr9B2g3-I-72m7pZDbRkxgY3hGBEKAONd8-prf9FanwGvY/?imgmax=800" width="368" height="134" v:shapes="Picture_x0020_7"></a></span><o:p></o:p></p> <p class="MsoNormal"><o:p> </o:p><b style="mso-bidi-font-weight: normal">Ok, so Let’s Get Started<o:p></o:p></b></p> <p class="MsoNormal"><font color="#004080"><strong>Prerequisites (…you need the following in place before you start coding):<o:p></o:p></strong></font></p> <ol> <ol> <li> <div style="text-indent: -18pt; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst" align="left"><span>the ID of the Ribbon Tab which you want to hide ( I created a custom ribbon tab –see elements file contents below)</span></div></li> <li> <div style="text-indent: -18pt; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst" align="left"><span></span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">the name of the SharePoint Security Group which can see the ribbon item</span></div></li> <li> <div style="text-indent: -18pt; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst" align="left"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></span><span>jquery-1.6.2.min.js</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> (download from </span><a href="http://docs.jquery.com/Downloading_jQuery"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><a href="http://docs.jquery.com/Downloading_jQuery)">http://docs.jquery.com/Downloading_jQuery</span></a>)</a></div></li> <li> <div style="text-indent: -18pt; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst" align="left"><span><span style="mso-list: ignore"><span style="font: 7pt 'Times New Roman'"></span></span>jquery.SPServices-0.6.2.js - t</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">his is a jQuery library which abstracts SharePoint’s Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install. </span><a href="http://spservices.codeplex.com/"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">http://spservices.codeplex.com</span></a></div></li></ol></ol> <p style="line-height: normal; margin: 0cm 0cm 0pt 18pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span class="MsoHyperlink"><b style="mso-bidi-font-weight: normal"><span style="color: windowtext; text-decoration: none; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin; text-underline: none"><o:p></o:p></span></b></span></p> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><font color="#004080"><strong>Development Tasks (…you will code the following):</strong></font></p></blockquote> <ol> <ol> <li> <div style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle">Construct the JQuery to hide the ribbon tab</div></li> <li> <div style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle">Register the JQuery to hide the ribbon tab</div></li> <li> <div style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle">Verify that it all works fine</div></li></ol></ol> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><font size="3"><font color="#004080"><strong></strong></font></font> </p> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><font size="3"><font color="#004080"><strong>Prerequisites:</strong></font></font></p></blockquote> <blockquote> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpFirst"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">1.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal">Get the ID of the Ribbon Tab which you want to hide:<o:p></o:p></b></p></blockquote> <p class="MsoListParagraphCxSpLast">If you have a custom ribbon tab then you can get the ID value from the Elements.xml file. In the example below the ID of my custom ribbon is ‘<span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">DemoHideRibbonTab’</span><o:p></o:p></p> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-tab-count: 1"> </span>?</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">xml</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">version</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">1.0</span>"<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>"<span style="color: blue">utf-8</span>"<span style="color: blue">?></span><o:p></o:p></span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-tab-count: 1"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Elements</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">xmlns</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1"> </span><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><span style="mso-tab-count: 1"> </span><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab</span>"<o:p></o:p></span></p> <p class="MsoListParagraphCxSpFirst">As an alternative you can use the following handy piece of JQuery to view the IDs of all the Ribbon Tabs on a page. <o:p></o:p></p> <p class="MsoListParagraphCxSpMiddle">Copy the JQuery code below and paste it inside a Content Editor Web Part on the SharePoint library AllItems.aspx page and save the page.<span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><o:p> </o:p></span></p> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><script type="text/javascript"></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"></span><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>$("a.ms-cui-tt-a").each(function () <o:p></o:p></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>{<o:p></o:p></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>var objTabTitle = $(this).parent().attr("id");<o:p></o:p></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>alert( objTabTitle );<o:p></o:p></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>});<o:p></o:p></span></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"></script></span></p></blockquote> <p class="MsoListParagraphCxSpMiddle">When you refresh the page the JQuery will iterate through all the ribbon tabs and display their IDs.<o:p></o:p></p> <p class="MsoListParagraphCxSpMiddle">You should see the IDs of the different ribbon tabs:<o:p></o:p></p> <p class="MsoListParagraphCxSpMiddle"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEie7N1PBqCXP6Gge8N-C4RNFhvLtV0nc0xXuWc_BWKT-PKc2HbieXnRcsXWIMjQJJ0fmsZRyGl1OWsNWbjZ_tGoVtVVwBsyattnpvuVK9AGb1kCIIF8uO43K7pMTCxp6Eumf_6eer9OQZE/s1600-h/clip_image006%25255B11%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image006" border="0" alt="clip_image006" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiemstw_iaI6me0bfWMvks1pgy_O4FIkIA9YEpxjaxAYO0wqFfqNZ0A-gDHWeQjofsrxGBqJFjSa2IISgKG69CKb-TnCr5d4ocao7sNAk6iovMVj5MxuuXfr74Y82ie39Vb8UU6DtUn_RQ/?imgmax=800" width="368" height="142" v:shapes="Picture_x0020_9"></a></span><o:p> </o:p></p> <blockquote> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">2.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal">Get the </b><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">name of the SharePoint Security Group</span>:<o:p></o:p></b></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle">The security group for which you must hide the ribbon tab must be a SharePoint group –it’s simple, you must have the name of the group.<o:p><strong> </strong></o:p></p></blockquote> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l1 level1 lfo2; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><strong><span><span style="mso-list: ignore">3.<span style="font: 7pt 'Times New Roman'"> </span></span>Download and distribute jquery-1.6.2.min.js</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><o:p></o:p></span></strong></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">The jQuery library is a single JavaScript file, containing all of its common DOM, event, effects, and Ajax functions. It can be included within a SharePoint page by linking to a local copy.<o:p></o:p></span></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Download jquery-1.6.2.min.js from </span><a href="http://docs.jquery.com/Downloading_jQuery"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">http://docs.jquery.com/Downloading_jQuery</span></a><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> and distribute into the 14-hive of your SharePoint web-front-end server.<o:p></o:p></span></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Example: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\HideRibbonSample\Scripts\</span> <span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">jquery-1.6.2.min.js</span></p></blockquote> <blockquote> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">4.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Download and distribute jquery.SPServices-0.6.2.js <o:p></o:p></span></b></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">This is a jQuery library which abstracts SharePoint’s Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install.</span></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Download jquery.SPServices-0.6.2.js from </span><a href="http://spservices.codeplex.com/"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">http://spservices.codeplex.com</span></a><span class="MsoHyperlink"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </span></span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">and distribute into the 14-hive of your SharePoint web-front-end server.<u><span style="color: blue; mso-themecolor: hyperlink"><o:p></o:p></span></u></span></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Exanple: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\HideRibbonSample\Scripts\</span> <span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">jquery.SPServices-0.6.2.js</span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></span> </p></blockquote> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><font size="3"><font color="#004080"><strong>Development Tasks:</strong></font></font></p></blockquote> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpFirst"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore"></span></span></b></p> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l1 level1 lfo2; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">1.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal">Construct the JQuery to hide the ribbon tab</b><b style="mso-bidi-font-weight: normal"><u><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><o:p></o:p></span></u></b></p></blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">We now have all the prerequisites in place and we can start coding the JQuery which will hide the ribbon tab.<o:p></o:p></span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Create a new empty file and save the file to the 14-hive of your SharePoint web-front-end server.<u><span style="color: blue; mso-themecolor: hyperlink"><o:p></o:p></span></u></span></p> <p style="line-height: normal; margin-bottom: 0pt; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Exanple: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\HideRibbonSample\Scripts\HideRibbonSample.js</span><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><o:p> </o:p></span></p> <p class="MsoNormal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Add the following JQuery to the file.</span><span style="line-height: 115%; font-size: 12pt"><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">function checkIfUserIsInGroup() <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">$(document).ready(function() { $().SPServices({<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>operation: "GetGroupCollectionFromUser",<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>userLoginName: $().SPServices.SPGetCurrentUser(),<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>async: false,<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>completefunc: function(xData, Status) {<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>if($(xData.responseXML).find("Group[Name='Root Visitors']").length == 1)<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>{<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>return "true";<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>}<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>else<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">HideTab();<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>return "false";<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>}<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>});<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>});<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">}</span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"></span><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><o:p> </o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">function HideTab() <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">$("a.ms-cui-tt-a").each(function () <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">var objTabTitle = $(this).parent().attr("id");<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">if(objTabTitle == "DemoHideRibbonTab-title")<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">$(this).parent().hide();<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">});<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><o:p> </o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">var ribbonSelected;<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">function checkRibbonState() { <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>var id = $("li.ms-cui-tt-s").attr("id");<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>if (ribbonSelected != id) <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>{<span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>ribbonSelected = id;<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>checkIfUserIsInGroup(); <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><o:p> </o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">function beginCheckRibbon() <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">var checkRibbonStateInterval = setInterval("checkRibbonState()", 10);<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>}<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">$(document).ready(function () <o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">{<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span>setTimeout("beginCheckRibbon()", 1000);<o:p></o:p></span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt">});</span></p> <p style="margin: 0cm 0cm 0pt 36pt" class="MsoNormal"><span style="line-height: 115%; font-family: consolas; color: blue; font-size: 9.5pt"></span> </p> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpFirst"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore"></span></span></b></p> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l1 level1 lfo2; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">2.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal">Register the JQuery as a custom action on the relevant ribbon tab</b></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle">Open the elements.xml file in which your custom ribbon tab is defined.<o:p></o:p></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle">You have to register the JQuery scripts in the correct sequence.<o:p></o:p></p></blockquote> <blockquote> <p class="MsoListParagraphCxSpMiddle">Use the ScriptLink class to register the following scripts:<o:p></o:p></p></blockquote> <p style="text-indent: -18pt; margin-left: 72pt; mso-list: l1 level2 lfo2; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">1.<span style="font: 7pt 'Times New Roman'"> </span></span></span>The jquery-1.6.2.min.js script.<o:p></o:p></p> <p style="text-indent: -18pt; margin-left: 72pt; mso-list: l1 level2 lfo2; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">2.<span style="font: 7pt 'Times New Roman'"> </span></span></span>The jquery.SPServices-0.6.2.js script.<o:p></o:p></p> <p style="text-indent: -18pt; margin-left: 72pt; mso-list: l1 level2 lfo2; mso-add-space: auto" class="MsoListParagraphCxSpMiddle"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">3.<span style="font: 7pt 'Times New Roman'"> </span></span></span>Your custom JQuery Hide Ribbon script.<o:p> </o:p></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span> </p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/jquery-1.6.2.min.js</span>"<span style="color: blue"> </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">100</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">SPS_SERVICE_JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/jquery.SPServices-0.6.2.js</span>"<span style="color: blue"> </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">101</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><o:p> </o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">JohanHideTab_JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/HideRibbonSample.js" </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">102</span>"<span style="color: blue">/></span></span><o:p> </o:p></p> <blockquote> <p class="MsoListParagraphCxSpLast"> </p> <p class="MsoListParagraphCxSpLast">My complete Ribbon Tab definition with the script registration is as follows:<o:p></o:p></p></blockquote> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><?</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">xml</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">version</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">1.0</span>"<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>"<span style="color: blue">utf-8</span>"<span style="color: blue">?></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Elements</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">xmlns</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Location</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">CommandUI.Ribbon</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">RegistrationId</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">101</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">RegistrationType</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">List</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIExtension</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinitions</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinition</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Location</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Ribbon.Tabs._children</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Tab</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab</span>"<span style="color: blue"> </span><span style="color: red">Title</span><span style="color: blue">=</span>"<span style="color: blue">Show or Hide Tab</span>"<span style="color: blue"> </span><span style="color: red">Description</span><span style="color: blue">=</span>"<span style="color: blue">Show or Hide Tab</span>"<span style="color: blue"> </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">501</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Scaling</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.Scaling</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">MaxSize</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.OneLargeGroupMaxSize</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">GroupId</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.OneLargeGroupExample</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Size</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">OneLarge</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Scaling</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Groups</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.GeneralControls.Groups</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Group</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.OneLargeGroupExample</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Description</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Contains custom controls</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Title</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Show Message</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Sequence</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">55</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Template</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Ribbon.Templates.OneLarge</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Controls</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.OneLargeGroupExample.Controls</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Button</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">DemoHideRibbonTab.OneLargeGroupExample.Controls.Button</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">LabelText</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Show Message</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Image16by16</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">/_layouts/images/newtargetapp16.png</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Image32by32</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">/_layouts/images/newtargetapp32.png</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Command</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">COB.Command.SayHello</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Sequence</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">10</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">TemplateAlias</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">custLarge1</span>"<span style="color: blue"> /></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Controls</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Group</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Groups</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Tab</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinition</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinition</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Location</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Ribbon.Templates._children</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">GroupTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Ribbon.Templates.OneLarge</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Layout</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Title</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">OneLarge</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">LayoutTitle</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">OneLarge</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Section</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Alignment</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Top</span>"<span style="color: blue"> </span><span style="color: red">Type</span><span style="color: blue">=</span>"<span style="color: blue">OneRow</span>"<span style="color: blue">></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Row</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ControlRef</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">DisplayMode</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">Large</span>"<span style="color: blue"> </span><span style="color: red">TemplateAlias</span><span style="color: blue">=</span>"<span style="color: blue">custLarge1</span>"<span style="color: blue"> /></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Row</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Section</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Layout</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">GroupTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinition</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIDefinitions</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIHandlers</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIHandler</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">Command</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">COB.Command.SayHello</span>"<o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></span><span style="font-family: consolas; color: red; font-size: 9.5pt">CommandAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">javascript:alert('Hello World');</span>"<span style="color: blue"> /></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIHandlers</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CommandUIExtension</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><o:p> </o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/jquery-1.6.2.min.js</span>"<span style="color: blue"> </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">100</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">SPS_SERVICE_JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/jquery.SPServices-0.6.2.js</span>"<span style="color: blue"> </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">101</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"><span style="mso-spacerun: yes"> </span><</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">CustomAction</span><span style="font-family: consolas; color: blue; font-size: 9.5pt"> </span><span style="font-family: consolas; color: red; font-size: 9.5pt">Id</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=</span><span style="font-family: consolas; font-size: 9.5pt">"<span style="color: blue">JohanHideTab_JohanJQuery.Script</span>"<span style="color: blue"> </span><span style="color: red">Location</span><span style="color: blue">=</span>"<span style="color: blue">ScriptLink</span>"<span style="color: blue"> </span><span style="color: red">ScriptSrc</span><span style="color: blue"> =</span>"<span style="color: blue">/_layouts/HideRibbonSample/Scripts/HideRibbonSample.js" </span><span style="color: red">Sequence</span><span style="color: blue">=</span>"<span style="color: blue">102</span>"<span style="color: blue">/></span><o:p></o:p></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"></</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Elements</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">></span></p> <p style="line-height: normal; margin: 0cm 0cm 0pt 36pt; mso-layout-grid-align: none" class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span><b style="mso-bidi-font-weight: normal"><o:p> </o:p></b></p> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l0 level1 lfo1; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"></p> <p style="text-indent: -18pt; mso-list: l1 level1 lfo2" class="MsoListParagraphCxSpFirst"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore"></span></span></b></p> <blockquote> <p style="line-height: normal; text-indent: -18pt; margin-bottom: 0pt; mso-list: l1 level1 lfo2; mso-add-space: auto; mso-layout-grid-align: none" class="MsoListParagraphCxSpMiddle"><b style="mso-bidi-font-weight: normal"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">3.<span style="font: 7pt 'Times New Roman'"> </span></span></span></b><b style="mso-bidi-font-weight: normal">Verify that it works fine</b></p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal">Build, Package and Deploy your custom ribbon feature.</p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal">Deactivate and Activate the feature in your site and refresh the SharePoint page on which the ribbon should appear (because the registration ID of my ribbon is ‘101’ the page which I should see the ribbon tab is http://demoweb/Shared%20Documents/Forms/AllItems.aspx.<o:p></o:p></p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal">If I am a member of the ‘Root Visitors’ group then the tab is visible.</p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image005" border="0" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdlcKimF_4R2Q3ZVtMfhuhgXQzSXhwU6FIndfH5Ea7273kc7SKlmAesjUr_R3LQxLOQyeo5UMzkeJQXagf2ev7ceGYcA1g4R1kAF-QcRwRxPVdPEiNo3pZ0ViH_j220kCAbIzQAu1WehY/?imgmax=800" width="368" height="134" v:shapes="Picture_x0020_3"></span> </p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal">If I am not a member of the ‘Root Visitors’ group then the tab is not visible.</p></blockquote> <blockquote> <p style="line-height: normal; margin-bottom: 0pt; mso-layout-grid-align: none" class="MsoNormal"><span style="mso-fareast-language: en-gb; mso-no-proof: yes"><a href="http://lh4.ggpht.com/-WPGrN-6azeY/Tt4SehSbZLI/AAAAAAAAAoI/PDAN_v4vRC0/s1600-h/clip_image003%25255B23%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image003" border="0" alt="clip_image003" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjT05_izVJnAqmMsrInNxarVP9n3NdM4M0Xh1e08PNxxHzVMvdjxwC26B0nqu0NUheIle5wnaIgJs6IHA3giaUSlU9G743pSEQhNy5rpdW4CsBuiu40bFcjUe9bZ3r7mPMlHbS7SzqZe10/?imgmax=800" width="368" height="86" v:shapes="Picture_x0020_5"></a></span></p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal"><b style="mso-bidi-font-weight: normal"></b> </p> <p style="margin-bottom: 0pt" class="MsoNormal"><b style="mso-bidi-font-weight: normal">Enjoy!!<o:p></o:p></b></p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal"><span style="line-height: 115%; font-size: 12pt"></span> </p> <p style="margin-bottom: 0pt" class="MsoNormal"><span style="line-height: 115%; font-size: 12pt"><font size="2"><strong>References:<o:p></o:p></strong></font></span></p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal">Once again, thanks for the contributions made by members of the community.<o:p></o:p></p></blockquote> <blockquote> <p style="margin-bottom: 0pt" class="MsoNormal">Chris O’Brien: <a href="http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html">Ribbon Customizations</a> <o:p></o:p></p></blockquote> <blockquote> <p class="MsoNormal">Tobias Lekman: <a href="http://blog.lekman.com/2011/05/hiding-inactive-ribbon-commands-in.html">Hiding Inactive Ribbon Commands in SharePoint 2010 </a><span style="mso-spacerun: yes"> </span><o:p></o:p></p></blockquote> <p style="margin-bottom: 0pt" class="MsoNormal"><span style="line-height: 115%; font-size: 9.5pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><o:p> </o:p></span></p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com6tag:blogger.com,1999:blog-429025622434259152.post-34342838671814924712011-11-11T10:15:00.001+02:002011-11-11T11:26:11.459+02:00European SP Conference Exceeded Expectations<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDrFqTIXOGxa9RgBEEtm3urRyBc_1xLG8Ov_CIWn-S2cDeiVkqjihFEi5-m5RDtxT8YXByML39qn99TJJMEQE6aCGsPYNYIl7WNcFKv1vyAtEGTmEGshTYPmtK8QeMAOd0ffLnis3jH9U/s1600-h/clip_image001%25255B4%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjbJ9W9ZDYL7iIcFxfm06YEhQXrkKcm4ptqZy9Ueuy9qKiZEL6VidR8tJa5cpY0i-EwQ41LDTIDXKUg4CiDikeZYXbvSMnlmjzKR4-_ZIfnZWIVlJ7px19id-xxiAQ_HcTgQVGDmhekhE/?imgmax=800" width="579" height="208"></a> <p>Wow, time flies when you're having fun! <p>During the past few weeks I have been on a very exciting SharePoint journey during which I travelled almost 39 000 kilometres and took part in SharePoint activities in Istanbul, Berlin and New York. <p>Each stop was a very different experience and each SharePoint activity offered a unique view into the SharePoint world. <p>The European SharePoint Conference was the highlight of this tour and exceeded all my expectations. <p>I have been to many conferences before and I can without a doubt say that the European SP conference was out of the ordinary. <p><b><font size="3">A few highlights of the conference include the following:</font></b> <p><strong>· It was clear that we have moved on from the ‘<i>Understand SharePoint</i>’ topics to ‘<i>Let’s provide solutions</i>’ topics.</strong> <p>Conference content and vendor exhibitions were aimed at how to extend SharePoint with custom development and 3rd Party value-add features in order to provide better solutions. Strategic thinking was the order of the day and I am sure that over the course of the 3 days a significant number of industry leaders had to at some point shift their thinking from product to solution. For me as a solutions architect it is very exciting to experience how well established SharePoint is in the industry and that we are now comfortable enough to move on to a next phase in the SharePoint lifecycle. <p>As an example of how far we’ve come, a few years ago we had topics like ‘<i>What’s new in SharePoint workflow development</i>’. This year at the EUSPC 2011 we had a SharePoint Shootout session for workflow during which various workflow products were compared in order to help architects and decision makers to understand the differences between the available workflow engines. <p>· <b>I experienced an instant comradeship between delegates and solid friendships were established</b> <p>This is without a doubt the most important take-away from the conference. It is normally quite a challenge to ensure we make most of a conference by not allowing for the experience to end at the closing keynote. The SharePint event and other similar social get-togethers provided a great way for us to connect, have a beer (or few) and socialize. I have made friends with SharePoint comrades from around the world and appreciate that we can stay connected and exchange ideas and support one another. <p>· <b>Great Presentations </b> <p>The 45 minutes allocated per session was not enough time to provide a proper introduction, do a knowledge transfer and take some questions. Many delegates expressed this concern and I also battled during my presentation to stay within time. <p>However, the benefit of short sessions is that the audience receive high-impact and to-the-point presentations. <p>The speakers came from across the world to share their experiences and having 4 simultaneous tracks ensured that a wide spectrum of SharePoint topics were covered. <p>The presentations are available for download on the <a href="http://www.sharepointeurope.com/conferences/2011/conference-programme-at-a-glance.aspx">conference website</a>. <p>(The presentations are immediately available to delegates and will be available to the general public after 25 November 2011) <p><b></b> <p><a href="http://lh6.ggpht.com/-KGxRFDjSLuU/TrzY8Ok93wI/AAAAAAAAAjA/2I9GkHCeyoQ/s1600-h/clip_image002%25255B4%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9A6OhM4V5aBDp52tJqPHGfeGaGeAxIi4Omxxscfp2SG0C9emOElJtLxhIMjxd-QyZOr66cludIGCgfg8sMCOU1dljeZt9HAhrB9sNo9vz7hV74HNihqY04tL7KknZ3CYFQmT4bv9CV8o/?imgmax=800" width="579" height="423"></a><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWB6iwmd5xH1kneCeH-9YoLO_XU4Xokr5Tu9H49lpkBoWGIrGNPOxJ1nLjkOJ4iaxTjZiiDaYQbmkdlipm12JIZ6oK2iIAhvtsTSrMm_l_56TYif8jFAvZ2f1ANG-3TCleqQ_0j6-97mk/s1600-h/clip_image003%25255B4%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://lh5.ggpht.com/-6T0oD_bS3-g/TrzZJoE-PjI/AAAAAAAAAjY/rDQLAKoIZ8U/clip_image003_thumb%25255B1%25255D.png?imgmax=800" width="579" height="399"></a></b> <p><b></b> <p><b></b> <p>· <b>Exhibitors showcased valuable solutions applicable to solving real-world challenges</b> <p>I am very impressed with the products which the vendors showcased. As a solution architect I always try to keep a wide range of SharePoint solution enablers in my toolbox and I am very excited to see that there is a very high industry standard and that the vendors do help us to take SharePoint further through rapid implementation of great add-ons. <p><b></b> <p>· <b>The conference was very well organized</b> <p>Hats off to Helen, Mary, Declan, Tracy, and the rest of the European SharePoint team for doing a brilliant job in planning and coordinating the event. Everything went very well and I had a great time overall. <p><b></b> <p><b>Content:</b> <p>90 presentations were delivered across 4 tracks (IT DM, IT Pro, Dev and Gen). The 4 tracks provided a very rich selection of outstanding topics and at times made it difficult to choose which one of simultaneous presentations to attend. The 60 speakers came from across the globe. There was an obvious variance in the quality of the presentations but some were really good. <p>What I did pick up from most sessions is the fact that the speakers tend to jump in and start showing code and technical know-how without taking the time to explain to the audience how they can benefit from the feature. I believe it is extremely important for the audience to appreciate the importance and value-ad of a technical discussion before the code syntax is explained. The occasional lack of proper introductions and closing statements could be because the sessions were limited to 45 minutes each. <p>The presentations are available for download by the public after 25 November on the <a href="http://www.sharepointeurope.com/conferences/2011/conference-programme-at-a-glance.aspx">conference website</a>. <p><b></b> <p><b></b> <p><b>SharePint:</b> <p>AvePoint hosted a “Red-Party” on the second night of the conference but could only accommodate a limited number of people and many of us who registered for the party were disappointed to find out that we did not collect the entrance tags in time and therefore could no longer attend. <p>Fortunately on the Tuesday afternoon, in an effort to offer an alternative social gathering for attendees unable to attend the AvePoint party, a SharePint event was organized and co-sponsored by Qorus, Axceler, Newsgator, Metalogix, and HiSoftware. Arrangements were made, flyers were handed out, tweets were sent out, and a few hours later we enjoyed free German beer, great company and awesome music at the <a href="http://www.amtopm.de/">AM to PM Bar</a> located in Hackescher Markt, one of Berlin’s coolest locales. <p><b></b> <p>Many thanks to Qorus, Axceler, Newsgator, Metalogix, and HiSoftware for organizing and sponsoring the great evening! <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicv6PDklXHMrq2oCHAMXvJYmsRU3_8mT81FQi_jk8WQA2DPsPWlAuEjdyGOL4e9oEPBZOwlHENMwsdXtBP6ddYJ5ebmTPS0MHcOt5WQgh4sCgitHkI_8xAw7e3mxmliJxES4yQxjhWZvE/s1600-h/clip_image005%25255B5%25255D.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image005" border="0" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaQ6XatFhUj2QKmFp4baK6KqC63p9ZVAmKVTjd2Zl4n67wm8sbl9NKY2rog3v-I8my-CsOUEu0J3hwcxwcrLiscQkAFFRxXAO8Jg-DcokLG1Em-2MNyVqiERN6C_jIL2BVcgi9Ab6_F_s/?imgmax=800" width="579" height="439"></a><b><br></b> <p><b></b> <p><b>Solution Enablers:</b> <p>I was very impressed by the products and services showcased by the exhibitors. It is always important to understand when to develop custom solution parts vs. when to make use of 3-rd party solution enablers. And having the right mix between technical presentations and a wide range of exhibitors at the conference gives me the confidence that SharePoint solution architects will take a step back and carefully consider how a mixture of SharePoint OOB features, 3<sup>rd</sup>-party products and custom development can solve business requirements. <p>Once again, think “solution” and not single product. <p>See the section ‘Interesting solution enablers’ at the bottom of this blog for a brief overview of a few of the products available. <p><b></b> <p><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5hbkgkjPY2S4EyraE_ISXvKQDJt-4LHB1XwaXswcejLQU8Xl_nGZOJZL6RFV-Fg1HZjAIPw9VK56a-JqzvCQwPgr6w_DgwDhWdiApspRZumvhxAuGkDc6qWZXQVgaXoFdI0O3U66CjMk/s1600-h/clip_image006%25255B4%25255D.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="clip_image006" border="0" alt="clip_image006" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8bXwshaujAiGAgjB9VZzCydBzMHg0_IRROE0-6ksVkTtSuZQ_C7tvJIItwnUDfhIOvK2Dz7He7UWFlwXe3ytf_adwRFDKfPS67eEO9CDtXkTNTRr9ZamK3McIWpiIAhxrmqp-RUiNqZQ/?imgmax=800" width="331" height="520"></a></b> <p><b></b> <p><b>Immediate Actions:</b> <p>There are thousands who did not have the opportunity to attend the conference. It is our responsibility to take the conference into the workplace and I cannot wait to share the relevant knowledge with my team and local community. <p>I am already in touch with a number of speakers, vendors and delegates and I will trial / explore some of the products, download and research some of the presentations and use my findings to conduct at least 5 geek-talk-round-table discussions with my team in order to see how we can benefit from the conference content. <p><b>Conclusion:</b> <p>Overall a very well organized conference with great structured content relevant to solving problems which we currently experience in the SharePoint industry. <p>A fantastic vibe between conference delegates, great relationships established and an absolute great experience. <p>Well done to everyone who participated and please continue with your efforts to share the knowledge and passion for SharePoint with those around you! <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgocf3vGi30fIvmLxrWQioIgLyaYExqlcIG22TJ3pnmgYcEw_XkKDREL_b3tQ9xYktJoa3OOzQakKyRmM-ZzxEanTSsGsjBNTBh9jp7U-FuJMZ1ALUCxZElSFrJljELtrOAHg92pLNt-tU/s1600-h/clip_image007%25255B5%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image007" border="0" alt="clip_image007" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiO2Cx6yw8r-qsfd2cHH2aTLFYEkFHIaO-AXuywX7Tys70UVS1pU-WcqGUxHNtM4lyd9qtwcfi5gNEhGzdgj6zKCkdS_Lh5Ah67mF4yhnn581fN4Tt7DM9TnFqC8dZyHV0pfOY5A3u8i8/?imgmax=800" width="579" height="467"></a> <p><b><br></b> <p><b></b> <p><b><font size="3">Interesting Solution Enablers:</font></b> <p><b><u></u></b> <p><b>Qorus Software </b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXnZ5Ndp6LdaFkYhZBhEcgtWS_i2mb6_W3nfEoThnIWypMbmA8XSqvsQTEKsVdHGIqF8aXX-10P2O_M8RMc3HCCVe1CcIMlYqS_dE3ja3SZhklSjeM8ecntRVSGcjeqVddgC2q8rYvLww/s1600-h/clip_image009%25255B3%25255D.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image009" border="0" alt="clip_image009" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFxJrcEhr0Pl-WMBMgupEimL4FMBFp_DHddtIGBo_xQ4QSgjMVwaj44sQRoNTVYpukreIWwxYDXGkAy6mOuE5bt8bFySoG2RXW3-zJ4B9jP7Jqes6amqyTjcRGgXyLUsfnJjW_nAYi0Pw/?imgmax=800" width="108" height="110"></a></p> <p>Qorus DocGeneration works with Microsoft SharePoint 2007 / 2010 and Microsoft Word to dramatically reduce the time and effort required to generate complex, customized documents while improving quality, consistency and effectiveness. <a href="http://www.qorusdocs.com/">http://www.qorusdocs.com/</a></p> <p><b></b> <p><b></b> <p><b>SurfRay – Ontolica Search</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4hE7ltraDVQxpY5n4kB8nkVnPDYg_GmWscVkllqH15AndTFVxjiBgP9s6kTXBcXRo9gqdmSdM7yQSYJXtQBn4hkmeZhoKekEf72GWsccvGryNyY4nBQrcmptqKCqkL52XHUZQGNM37w4/s1600-h/clip_image010%25255B3%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image010" border="0" alt="clip_image010" src="http://lh4.ggpht.com/-OXBVrv20nHc/TrzZYvt1OYI/AAAAAAAAAko/Uru4e7veb5k/clip_image010_thumb.png?imgmax=800" width="219" height="64"></a> <p>Ontolica Search Preview allows you to preview and read documents in any format directly in SharePoint search results, with hit highlighting, and navigation to the most relevant pages in your documents . This reduces search costs and increases user adoption dramatically. <a href="http://www.surfray.com/">http://www.surfray.com/</a> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b>NewsGator</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjG5SW5wyz-FCma1oJ7PwezjVUb_ni4tdmK9X-ErfsqO5KiJvBJOY3x8sc3uUSOMNYCYSAs0kKtiQHrVt_NsBVltcrU0qbj_rM8dEjewYf3B8B9tOft4x3PQvF_1LuC1NCEa65fa9ExSIk/s1600-h/clip_image011%25255B3%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image011" border="0" alt="clip_image011" src="http://lh4.ggpht.com/-4VDMY1tkiGo/TrzZafESyhI/AAAAAAAAAk4/1E4F9zQ6B8c/clip_image011_thumb.png?imgmax=800" width="244" height="62"></a> <p>NewsGator solutions help you overcome business challenges by providing an integrated, behind-the-firewall, social computing platform that supports collaboration, facilitates communication, and improves worker knowledge. <a href="http://www.newsgator.com/">http://www.newsgator.com/</a> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b></b> <p><b>Kaldeera</b> <p><b><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuJxBCCvIwMLpGX6djsNYO4XSosJFn7pt5Y-1KGqmW6xuRIqk7ZYo38RyEdL9_la1Ro1E1yzahAycbDyIvMnDg0Anmw7yIDC158JD_knm2ObF7gjztdwKwq7li3QlqTKbZMYhI5QxAR-0/s1600-h/clip_image013%25255B3%25255D.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image013" border="0" alt="clip_image013" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdf4UwUlS4HnaHwskdR68N5zbKTBDwwvnGpw5wJBvvk3ee_rTLcBQWtkYuAl3Wl1isprVNp9q0zro8UJX7IQ-Qmeev-hw4F_DLQH_X74cdbyc6lSjRh9np025HBUR5Mc5PmG2V3PsaziI/?imgmax=800" width="205" height="76"></a></b> <p>KAF is a tool that allows you to <b>modify the standard SharePoint® forms</b> and create powerful web form-based applications. Hide fields, display "uneditable" fields, grouping and display the information in a more intuitive way adding static text, images, Web Parts, etc. <a href="http://www.kaldeera.com">http://www.kaldeera.com</a> <p><b></b> <p><b>GetOrganized</b> <p><b></b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhRaHqK6lpZv3OhCXKCb-fx9U5vzl2TZC2yPg8GX2daJNOCEQfg3F3EMg1hhyphenhyphenmrMMUMUhm7zS_JtF9HFj3xG6ztEgjaulon27G3hwrqQNFRek63mwrTnMorbCaWgSxxhZsarlnFHTzizI/s1600-h/clip_image014%25255B3%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image014" border="0" alt="clip_image014" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjW6LLi58MfhwtfXuiXK4RhfgSPbPIvumkMPEA5WSPpT9d0tam9DIT1AjxdYzV7X1VeJHhLmjVuxYOYh3XWOkEJceol2_SxIHFelBbeejRfBwVkAe2R0VXdBNsBCgwZhkrSEt9b5YMnjBM/?imgmax=800" width="244" height="65"></a> <p>In brief GetOrganized is a user friendly standard product which organizes e-mails, documents, tasks etc. in a relevant context in order to optimize collaboration and business processes in your company in a simple and efficient way. <a href="http://en.getorganized.net">http://en.getorganized.net</a> <p><b></b> <p><b>Bamboo Solutions</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFoFWUKBIKk4qC_fX4ylbw_AXsOGaJwz2VuDAVLDWj50lyGFJczeP3UkonWm9Z7I6XIqb0kpSgec_OuDjWDZbK1y31jfUljjd1qDvr5E3KjU6vOYi4mcoEHT4iTcwd1Ars2vZqOQguDbs/s1600-h/clip_image015%25255B3%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image015" border="0" alt="clip_image015" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTPbnFpwBAXzlQsYsSXis-CdUQaLpS1S8Vwug2uCElqHfF2EA7XRBm5qK0hOUnI2xchjII-aXLv8Z6HxwDWB7Z8VdlW8booBYSsxFJj-depdOA5GDKscd2RSh496IxYh7iM8xHptvg22k/?imgmax=800" width="223" height="56"></a> <p>Bamboo® Solutions provides technologies that augment the SharePoint platform, and more than 60 products that provide a broad range of enhanced capabilities and solutions that maximize the value of SharePoint deployments. <a href="http://bamboosolutions.com">http://bamboosolutions.com</a></p> <p><b></b> </p> <p><b>MetaLogix</b></p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2qAIfyLCT5I-57q2fjuWyYr6QEAwSFoVTi9B8pKAflyHs3ZR-Rs0QdmNJ30Sg2K8jHidreiTQUfpzQgHyjJwLqEsoQHJYnLyYneRVkNLlp-UPTdFeIB4exidu03Aq2kHxsyPedUctNDU/s1600-h/image%25255B2%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkhVPBp8jWpF7u8rKGSro5JmaYiT_YwKMZT095eqyuA2CiU-Oy4UmEBnjTwHIuqNz978q7DEHLoqBjTnZu-z4CHTHiCrOA5LIIgEh8ITlT1XuWxN3KlCkRetbZICyNePlRnjA5EqmrcwQ/?imgmax=800" width="205" height="55"></a></p> <p>Provides comprehensive content lifecycle management solutions that allow you to easily move data, reduce compliance risk, cut the cost of discovery, reduce storage and simplify management of Microsoft content, whether it’s on-premises or in the cloud. <a href="http://www.metalogix.com">http://www.metalogix.com</a></p> <p><b></b> <p><b>Axceler</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIPG8fmKpTMbIEl9cDCybcIwOkHjYFVMFdTML2dZ07QOBQOKajxNmdK4Ha8AIUSkcaUo-3n3Mj2D_Y-KKTgSpNR4TGMHSKXEkJotreQarSA60xZVH3433GJOIzRgMHM-gnw6HZljXguzI/s1600-h/image%25255B5%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtZ_MePFBQofqxh4CAKrZ4XcI-_QZFiE3yEmy-DSQiosivqTeGC9w7luUGQFngJmNQuL5eFh17n3eNDNHSYjDa_PJfePR9glz1GyCap4KjK71ba-XTdrXPkmSvfpYl59j7bBJYmWKCrvQ/?imgmax=800" width="179" height="73"></a> </p> <p>Axceler provides SharePoint solutions that help the SharePoint management team get the most out of their platform and address the most pressing SharePoint challenges facing enterprises today. Solutions include SharePoint Governance, SharePoint Administration, SharePoint Migration, SharePoint Security, SharePoint Reporting and SharePoint Visibility. <a href="http://www.axceler.com">http://www.axceler.com</a></p> <p><b></b> <p><b>HiSoftware</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhE8XjZT7eLke6k0ZIwtfnqWWF9UJ6cEYmITcA1OjPDBIHn_I109OxsKj5r3_-_ex_ktGePwtf-RZUqYQLvUZ7zsGL7qKr1cz0vzyk_ennyS_BwiSN0cyXRq1wzkiKjkPLfVKahy9Cb8MI/s1600-h/image%25255B8%25255D.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzf58HfIiNtrXn8n6XDItnDdcK7C2Spbm-7mxJQ-uyPr4RxJ00cquPdFB7TlKGPf5mNHR0PMQv1wsbDXec8wEQ2E2HtmxRum7r30h0BXAkYzVE0pkAgF43zFrCTo6QUEF_4JPLkLp0YeA/?imgmax=800" width="183" height="63"></a> </p> <p>HiSoftware provides content-aware compliance solutions for both Web and SharePoint® environments that detect private or confidential data and report on violations to ensure compliance with regulatory and other internal policies. <a href="http://www.hisoftware.com">http://www.hisoftware.com</a></p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com1tag:blogger.com,1999:blog-429025622434259152.post-54211990927036884942011-06-28T16:04:00.001+02:002011-06-28T16:34:16.497+02:00Authentication Methods for SP2010 Client OMOn 25 June 2011 I presented a session at SharePoint Saturday India on the topic of the ‘SharePoint 2010 Client Object Model’. One of the questions which were asked was around the various authentication methods when using the Client Object model. <br>This short post will describe the authentication methods available when using the SharePoint 2010 .Net Managed Client Object Model. <br><b></b><br>The 3 Object Models with their available authentication methods are: <ol> <li><strong>.NET Client Object model </strong> <ul> <li>The default is to authenticate users via their current Windows credentials (NTLM and Kerberos). <li>Possible for you to define other authentication methods like Anonymous or Forms Authentication. </li></ul> <li><strong>Silverlight Client Object model</strong> <ul> <li>Default is to authenticate users via their current Windows credentials (NTLM and Kerberos). <li>It is possible for you to define other authentication methods like Forms Authentication. <li>It is <strong>not </strong>possible to use the Silverlight client object model with anonymous authentication. </li></ul> <li><strong>ECMA Script Client Object model </strong></strong> <ul> <li>No need for additional authentication as JavaScript already runs in an authenticated page. </li></ul></li></ol> <p><strong><font size="3">Authentication Methods when using the .Net Client Object Model</font> </strong></p><a href="http://lh6.ggpht.com/-yGelrL0iXAQ/TgnfaoceSZI/AAAAAAAAAik/Wf1Y0SE3p3E/s1600-h/image%25255B4%25255D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6rGnk-L-SyEq4m1gDCVwLRxDAN7FS0HjpFlSGS27_We1zSDCPjycCf76adikYReaL4CQT01EL3Kapi7iQWy8pBFykNhvnCpbHGP9J5fq_QdYXMBBZX6jzJ2awK9W4OoviV0HwE2PhN6k/?imgmax=800" width="495" height="309"></a> <p></p><br>The Microsoft.SharePoint.Client namespace provides a ClientAuthenticationMode enumerator.The members are: <p></p> <ul> <li><b>Default:</b> Represents the default authentication mode. <li><b>FormsAuthentication:</b> Represents ASP.NET forms authentication mode. <li><b>Anonymous:</b> Represents anonymous authentication mode. </li></ul> <p>So in order to specify the authentication type you will have something like: <br><font color="#004080" face="Courier New"><font color="#004040"></font></font></p> <p><font color="#004080" face="Courier New"><font color="#008040">//Create a client context for my site which uses Forms Authentication</font> </font><br><font color="#000080" face="Consolas">ClientContext clientContext = new ClientContext("http://ltp-21:31890"); <br><font color="#008040">//Set the AuthenticationMode</font> <br>clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;</font></p> <p>If you use Forms Authentication you will have to set properties for an instance of FormsAuthenticationLoginInfo class and assign that to the client context (see example below). <br><b></b></p> <p>Note:<br>All the examples below are based on creating a .Net Windows Console Application. Remember to please add references to: <br><b>Microsoft.SharePoint.Client:</b> C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.dll <br><b>Microsoft.SharePoint.Client.Runtime:</b> C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Client.Runtime.dll <br></p><b></b> <p></p>The code for all three examples will: <p></p> <ul> <li>Create a client context for my site which uses a specific authentication method. <li>Instruct the client context that I want to load the sub-site. <li>Get the title of the site and write it to console.</li></ul> <p><b><font size="3">Default Authentication:</font></b> <br>In this example the client object model will connect through using the current Windows credentials (NTLM / Kerberos). <br>Because the default authentication method for client object model is NTLM / Kerberos we do not explicitly need to specify an authentication method. <br>Remember to replace the URL of the site with that of your environment. <br>In my environment the URL <a href="http://ltp-21:13111">http://ltp-21:13111</a> points to site configured for NTLM authentication.</p> <p><font color="#000080" face="Consolas">using System; </font><br><font color="#000080" face="Consolas">using Microsoft.SharePoint.Client; </font><br><font color="#000080" face="Consolas">namespace StdAuthSample </font><br><font color="#000080" face="Consolas">{</font> <br><font color="#000080" face="Consolas">class Program </font><br><font color="#000080" face="Consolas">{ </font><br><font color="#000080" face="Consolas">static void Main(string[] args) </font><br><font color="#000080" face="Consolas">{ </font><br><font color="#000080" face="Consolas">ClientContext clientContext = new ClientContext("http://ltp-21:13111"); </font><br><font color="#000080" face="Consolas">Web site = clientContext.Web; </font><br><font color="#000080" face="Consolas">clientContext.Load(site); </font><br><font color="#000080" face="Consolas">clientContext.ExecuteQuery(); </font><br><font color="#000080" face="Consolas">Console.WriteLine("Title: {0}", site.Title); </font><br><font color="#000080" face="Consolas">} </font><br><font color="#000080" face="Consolas">} </font><br><font color="#000080" face="Consolas">}</font><br><b></b><br><b><font size="3">Forms Authentication:</font></b> <br>In this example the client object model will connect through using Forms Authentication. <br>You have to explicitly set the authentication method to Forms Authentication by using the clientContext.AuthenticationMode. <br>Then you also have to specify the Authentication Login Info by creating an instance of FormsAuthenticationLoginInfo and setting the new clientContext.FormsAuthenticationLoginInfo to that of your FormsAuthenticationLoginInfo object. <br>Remember to replace the URL of the site with that of your environment. <br>In my environment the URL http://ltp-21:31890 points to a site configured for Forms Authentication.</p> <p><font color="#000080" face="Consolas">ClientContext clientContext = new ClientContext("http://ltp-21:31890");</font> <br><font color="#008040"><font face="Consolas">//Set the AuthenticationMode </font><br></font><font color="#000080" face="Consolas">clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication; </font><br><font color="#000080" face="Consolas"><font color="#004040"><font color="#008040">//Instantiate a FormsAuthenticationLoginInfo object</font>.</font> </font><br><font color="#000080" face="Consolas">FormsAuthenticationLoginInfo formsAuthInfo = new </font><br><font color="#000080" face="Consolas">FormsAuthenticationLoginInfo("MyFormsTestUser", "MyUserPassword!2"); </font><br><font color="#000080" face="Consolas"><font color="#008040">//Specify the login details using the FormsAuthenticationLoginInfo object.</font> </font><br><font color="#000080" face="Consolas">clientContext.FormsAuthenticationLoginInfo = formsAuthInfo; </font><br><font color="#000080" face="Consolas">Web site = clientContext.Web; </font><br><font color="#000080" face="Consolas">clientContext.Load(site); </font><br><font color="#000080" face="Consolas">clientContext.ExecuteQuery(); </font><br><font color="#000080" face="Consolas">Console.WriteLine("Title: {0}", site.Title);</font><br><b></b><br><b><font size="3">Anonymous Authentication:</font></b> <br>In this example the client object model will connect through using Anonymous Authentication. <br>You have to explicitly set the authentication method to Anonymous Authentication by using the clientContext.AuthenticationMode. <br>Remember to replace the URL of the site with that of your environment. <br>In my environment the URL http://ltp-21:12381 points to a site configured for Anonymous Authentication. </p> <p><font color="#000080" face="Consolas">ClientContext clientContext = new ClientContext("http://ltp-21:12381"); </font><br><font color="#008040"><font face="Consolas">//Set the AuthenticationMode </font><br></font><font color="#000080" face="Consolas">clientContext.AuthenticationMode = ClientAuthenticationMode.Anonymous; </font><br><font color="#000080" face="Consolas">Web site = clientContext.Web; </font><br><font color="#000080" face="Consolas">clientContext.Load(site); </font><br><font color="#000080" face="Consolas">clientContext.ExecuteQuery(); </font><br><font color="#000080" face="Consolas">Console.WriteLine("Title: {0}", site.Title);</font> <br></p> <p>I hope this will give you a simple but complete overview of the 3 authentication methods available when using the .Net Managed SharePoint 2010 Client Object Model. <br>Enjoy!!</p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com6tag:blogger.com,1999:blog-429025622434259152.post-11367254203819703562011-05-20T16:30:00.001+02:002011-05-20T16:40:00.851+02:00Improve SharePoint Search Relevance<p><b><font size="3">Introduction:</font></b> <p>I recently developed a SharePoint 2010 solution which includes an advanced search web part which allows the users to perform enterprise searches and view the returned results in a graphical rich representation. <p>As an architect I want to ensure that the search results that are returned to the user match what the user wanted to find and that the results that are returned on the first page are the most relevant, so the user does not have to look through several pages of results to find the best matches for their search. This is called Search Relevancy. <p>It is very important to realize the difference between <strong>Sorting</strong> and <strong>Ranking</strong>. In my own words I would describe Sorting as the process or arranging objects according to a specific attribute of the item. An example would be the books in a library. <p>Ranking is where an item takes precedence over other items based on a combination of attributes. Examples of this would be how tools in a workshop are arranged, how equipment is arranged in an E.R. room, how individuals are ranked based on the role they play in the military, or even how food items are arranged in the supermarket. One realize from these examples that there is no single property which can be used to determine the ranking of such items and that Ranking is based on the importance an item has in a given situation. <p><strong><font size="3">The Role of the SharePoint Architect:</font></strong> <p>Architects and developers place a lot of focus during development to ensure that search engine works well. Performance and Accuracy of search results are normally the main focus point. <p>Providing a comprehensive search solution requires that the architect considers the search experience from the end-user point of view. <p><b></b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-2_mKjKPLCpARbjj5ZuWZUkhyphenhyphenNwya5jDqyMVjmei4UsYu1hPCp-8GZ9GHSPW_6DWfGSg1xlek0GYNUv1a9MGxKwmcWYWXFkyFvkdZDCxA6qVvaymZHFG_xQHWeSWd08gmbXrIw2cttn8/s1600-h/clip_image002%5B5%5D.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="clip_image002" border="0" alt="clip_image002" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNnI2PCvVjnK80kII4UEmEFGX1DljE_F9KsBoUUb-IdMExG5F9FRca5UR-145h8ZaZsNsr5SIKs6OcypxhM008mdx6-ddwT-pXd8wTn65ZB0fSRc3JytOZJWu_ZnKtclvY3YEamH4tij0/?imgmax=800" width="363" height="288"></a> <p>The end-user is not really concerned about what happens on the server and will most likely not appreciate the effort which goes into building robust search engines. <p>Management spend up to 27% of their time looking for information and when using the Search functionality in your SharePoint solution only one question will be asked; “<i>Did I find what I was searching for on the first page of the results?” </i>If the item the user searched for is not part of the first 10 search result items then then user will most likely believe the item does not exist in the system. <p><b><font size="3">The SharePoint Search Ranking Model:</font></b> <p>Relevance is about how closely the search results that are returned to the user match what the user wanted to find. <p>SharePoint uses a formula to determine which items are most relevant but the end-users have a different view on what should be considered the most relevant items. Even different users who use the same solution might have different opinions about this. (To be honest I can relate to this as I will sometimes at home arrange our DVD collection in a particular order and another family member would prefer a completely different order) <p>As an example when the user performs a search using the keyword ‘Demo’ the SP Search Engine returns the items in the following order: <p><a href="http://lh5.ggpht.com/_SX0lCwhJEzc/TdZ7ArTYzlI/AAAAAAAAAhs/TX-a41U3hBw/s1600-h/clip_image003%5B6%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003" border="0" alt="clip_image003" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipOLvQaTs8jgAoSyt6CJ0z-076XalOhng5HcWbENM1WW-jij6oewV3wa-TZMSFNmx_uoaDVyUqsj_OHNOwsPA-4-0QatU9gLw59zHZn8PpDpWe1K8bUOwpju0jOqHGLqee7afPZJJvE5M/?imgmax=800" width="387" height="106"></a> <p>SharePoint evaluates all properties and even the contents of the documents returned in the search results and used a complex algorithm to determine which items are most relevant and which items are least relevant. <p>Users are not interested in algorithms and might not even consider the fact that the search engine also takes into calculation less obvious dynamics like “Click Distance”, “Document Location (URL Depth)”, “Document Popularity”, “Language Detection”, “File Type”, etc. In actual fact the algorithm is very complex and it is unfortunate that very few end users appreciate at how clever the search engine is. <p>Some users might feel that the search results should be ranked in a way so that the Title of the item is considered the most important determining factor. <p>In this example we executed the same search we tested earlier but because a different preference of ranking were specified two of the result items were allocated a lower ranking order and items where the Title field are closer to the search criteria used moved up in the ranking. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZQayPuQ_LHzC-He2RZU4zzw2ucuNjDJSbr2BxcXVFtS-l_E5OzSDKk9YyGLU9WPV0lQ_lblRIMIzeBdbPsYi-lkDws-WUeltr08RfdAJ_jQumnRmEkgTTTMHs1Xne3UzeAGUAN0Vcq9U/s1600-h/clip_image004%5B5%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtQs6Ghyphenhypheno7SX5l_a-b8nYAMOCDOFHQXpUuGQInCOJnE3OcPOhy84xNglztDS5Tkj_ZSJhGUMVJquXwwBfE1TqbL683ZyCGQRvoZfedBq9VlRm1KqM91j7fKO_iJ4-BjSFdW3Aro0YblY0/?imgmax=800" width="387" height="107"></a><b></b> <p>There might even be a requirement to rank the search results based on a custom field like ‘Client Name’. You can see from the same search results below the item where the search criteria was not found as part of the ‘Client Name field moved down in the ranking order and items which contains the search criteria in the ‘Client Name’ field moved up in the rank. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7z43ldD9V2YzKzx3yZX6_z65_iIlUfzP2wS_4XhFoWk6iHpnGfIQugdygnJSAX8-QD2nZ4xsAkdoshZquFJePV09L5xfMRf3UYKwQb43E8vFP9lg5b6DDCHyV4PKsGVvYWmUol9kAmhM/s1600-h/clip_image005%5B4%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image005" border="0" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwwrOOZXhGRs0wo-P-OzocPJbatnnTYiGk-rT_bVrdYsU2UYMRIeQN9nkTehL4nvV-DGPOH2vhigkT746OM2c3sIYQog0IE4Favju_zaMf6Y3GyhlbZ838cSjK3ydioyaUlu-4p_ncjso/?imgmax=800" width="387" height="100"></a><b></b> <p><b></b> <p>SharePoint Enterprise Search includes a ranking engine developed in collaboration with Microsoft Research. It is specifically tuned for the unique requirements of searching enterprise content. <p>The great news is that it is possible for IT Professionals to customize the way SharePoint rank search results. This can be done through creating a custom model (ranking model) and instructing SharePoint to use the custom model in a particular area of the solution or even to set the new ranking model as the default for SharePoint Search. <p><b></b> <p>This article will provide you with the necessary background SharePoint Ranking Models and will guide you through the process of creating and implementing your own custom ranking models. <p><b><br></b> <p><b></b> <p><b><font color="#0000ff" size="4">Let’s Get Started!!</font></b> <p><b></b> <p><b><font size="3">Structure</font> </b> <p>As a developer I used to hate this part of an article… the mumbo-jumbo theory stuff which can be very boring, but believe me, if you really want to become one of the best SharePoint professional you have to consider the ground-rules, even if they are not always applicable to the immediate problem which you are trying to solve. So here we go…. <p>Ranking Model are based on a XML schema which contains an unique identifier, name, description and specifics of the components as part of the formula when calculating numeric scores which indicate which search results are more relevant than others. (For those who are interested in the formula please research the BM25 rating model) <p>The formula to calculate relevance uses two areas of ranking called <b>Static</b> and <b>Dynamic</b> ranking. <p><b></b> <p><b><font size="3">Dynamic Ranking (query-dependent ranking)</font></b> is where the property values or content of an item affects the ranking score. As example the ‘Title’ field can be evaluated against the search criteria and the more important we consider the field to be, the higher the ranking score will be for items where the value in the ‘Title’ field have a closer match to the search criteria. <p><b><font size="3">Static Ranking (query-independent ranking)</font> </b>is where<b> </b>the content or property values of an item do not determine the ranking of the item. <p><b><font size="3">Dynamic Ranking contains the following components:</font></b> <ul> <li><b>Property Weighting </b>is used to assign a weighting to a property so that they are weighted more heavily in the relevance calculation. Configure this setting to a value between 1 and 75. <li><b>Property Length Normalization </b>– because properties of an item vary in length, evaluation of the values cannot be treated equally and we need to adjust the rank of a content item, based on the length of the property, and the length normalization setting. This only applies to properties that contain text.The range of possible values for this setting is 0 to 1. For long text-managed properties, you usually want to set this to a value near to 0.7, which is the approximate setting for the body property. For properties that contain a small amount of text use a value of approximately 0.5. <li><b>Title Extraction - </b>only performed on Microsoft Office files. In scenarios where the ‘Title’ field of an Office file does not accurately reflect the contents of the item (example when a title of a file is ‘Presentation 1’ or ‘Document 1’), Enterprise Search detects another candidate for title within the body of the content item, and includes this value with the actual title when calculating relevance. (I think this is really cool!)</li></ul> <p><b></b> <p><b><font size="3">Static Ranking contains the following components:</font></b> <ul> <li><b>Click Distance </b>is<b> </b>the number of links between a content item and an "expert" page linking to the content item. The more links that the crawler must travel from an authoritative page to the content item, the lower the relevance score. If there are multiple paths to a content item, relevance is calculated based on the shortest path. <li><b>URL Depth</b> refers to how many levels deep within a site the content item is found. The level is determined by reviewing the number of slash ("/") characters in the URL; the greater the number of slash characters in the URL path, the deeper the URL is for that content item. A large URL depth number can lower the relevance of that content. <li><b>Automatic Language Detection </b>determines the user's language based on "Accept-Language" headers from the browser they are using and content that is retrieved in the user's language is considered more relevant than content in other languages, with the exception of English language content. <li><b>File Type Biasing - </b>in most search scenarios, certain file types are more relevant than others. For example, HTML pages and Word documents are usually more relevant to a user's search than an Excel spread sheet or a plain text file.</li></ul> <p><b><font color="#0000ff" size="4">Tutorial (…the exciting part)</font> </b> <p><b></b> <p><b><font size="3">What you need:</font></b> <ul> <li>SharePoint Central Administration <li>SharePoint Site with a document library <li>5 Sample documents (no other content in site) <li>A Search Scope to the particular SharePoint site which you want to search in. <li>Understanding of Manage Metadata Properties (only if you want to search on custom site columns. <li>PowerShell <li>Utility or source code to test our ranking model</li></ul> <p><b></b> <p><b><font size="3">Test Harness:</font></b> <p>Before we build a new custom ranking model let us first develop a small utility to help us test our ranking model. (You can also export the standard SharePoint Core Search Results Web Part and modify the xml to specify the ranking model to use, but in most cases I prefer to use a test harness instead of making changes to SharePoint until I have finished quality assurance of my custom code). <p>Create a new Visual Studio console application and add the following code to your Program.cs class: <p>using System; <br>using System.Collections.Generic; <br>using Microsoft.SharePoint; <br>using System.Diagnostics; <br>using Microsoft.Office.Server.Search.Query; <p>namespace SP2010SearchSample <br>{ <br> class Program <br> { <br> static void Main(string[] args) <br> { <br> SPSite objSite = new SPSite("<a href="http://ltp-21:14111");">http://ltp-21:14111");</a> //Replace with yours <br> SPWeb objTargetWeb = objSite.OpenWeb("/"); <br> ResultType resultType = ResultType.RelevantResults; <br> //VERY IMPORTANT TO USE DEFAULTPROPERTIES instead of * <br> //Replace 'SPSearchDemoSearchScope' with your Search Scope Name <br> string strQuery = "SELECT RANK, Filename, Title, FROM SCOPE() WHERE <br> FREETEXT(DefaultProperties, '*demo* ') AND \"SCOPE\" = 'SPSearchDemoSearchScope' ORDER BY \"Rank\" DESC "; <br> FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(objSite); <br> fullTextSqlQuery.QueryText = strQuery; <br> fullTextSqlQuery.ResultTypes = resultType; <br> //This is where we will later specify the custom ranking model to use. <br> //fullTextSqlQuery.RankingModelId = ""; <br> ResultTableCollection resultTableCollection = fullTextSqlQuery.Execute(); <br> ResultTable resultTable = resultTableCollection[resultType]; <br> while (resultTable.Read()) <br> { <br> Console.WriteLine("Rank:" + resultTable["RANK"].ToString() + " Title:" + resultTable["TITLE"].ToString()); <br> } <br>} <br>} <br>} </p> <p><strong>Please note the following:</strong> <ul> <li>Your namespace will be different. </li> <li>Replace <a href="http://ltp-21:14111"><font size="1" face="Courier">http://ltp-21:14111</font></a> with your site URL <li>Replace <strong>'</strong><font color="#ff0000">SPSearchDemoSearchScope</font><strong>' </strong>with your Search Scope name. <li>I included a placeholder <strong>(</strong><font color="#008000" face="cour">//fullTextSqlQuery.RankingModelId = "";</font><strong>)</strong> to later specify our custom ranking model to use.</li></ul> <p> <p>Compile the application and run it. If there are no problems you should see the search results returned and ranked using the default SharePoint Ranking model. <p>You can also refer to: Best Practices: Writing SQL Syntax Queries for Relevant Results in Enterprise Search <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVnzrKcxYnW12jG99Z_vRjVtiUrRBnAs7tIqKoN9X6WbsBvl0EIXYG8YpnXgSHSM9xc5Ju34g_tzLJD36BP6b6xcHxw-X_JVQH7q3zZzZ2_0jkwCHbKUcum671atyzoJWBOZ3XDyAS1kA/s1600-h/clip_image003%5B1%5D%5B3%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003[1]" border="0" alt="clip_image003[1]" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1zp2TDE3gHQjR2XcVv80JAeUK9hPXacM50ahNU0gsH07DzCyw43aWP7fSRmfGu2biriC-Gawi_j_dlWJMQiBo7Dod_cZlLFHEh1UKDcJfECce6YLHI0Yz9N009YVOBvorkYtIZM4KxU4/?imgmax=800" width="387" height="97"></a> <p>Now that we have a test harness to use for testing different ranking models we can proceed to <b>Build and implement a new custom ranking model</b> <p>We need to following values in order to construct our xml:</p> <p> <table border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="167"> <p><strong>Item</strong></p></td> <td valign="top" width="152"> <p><strong>Description</strong></p></td> <td valign="top" width="340"> <p><strong>How to find value</strong></p></td></tr> <tr> <td valign="top" width="167"> <p><strong>Name</strong></p></td> <td valign="top" width="152"> <p>The name of your custom ranking model</p></td> <td valign="top" width="340"> <p>Any value you want to use.</p></td></tr> <tr> <td valign="top" width="167"> <p><strong>Id</strong></p></td> <td valign="top" width="152"> <p>The unique identifier for the ranking model</p></td> <td valign="top" width="340"> <p>Use GUIDGen Tool to create a new GUID.</p></td></tr> <tr> <td valign="top" width="167"> <p><strong>Description</strong></p></td> <td valign="top" width="152"> <p>A description of your ranking model</p></td> <td valign="top" width="340"> <p>Any text you want to use.</p></td></tr> <tr> <td valign="top" width="167"> <p><strong>One or more queryDependentFeatures</strong></p></td> <td valign="top" width="152"> </td> <td valign="top" width="340"> </td></tr> <tr> <td valign="top" width="167"> <p><strong>pid</strong></p></td> <td valign="top" width="152"> <p>The property ID of a managed property in the search schema.</p></td> <td valign="top" width="340"> <p>Run the following PowerShell command to export all the PIDs to a text file: <p>Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchMetadataManagedProperty >> C:\PID.txt</p></td></tr> <tr> <td valign="top" width="167"> <p><strong>name</strong></p></td> <td valign="top" width="152"> <p>The name of a managed property</p></td> <td valign="top" width="340"> <p>Run the following PowerShell command to export all the Property names to a text file: <p>Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchMetadataManagedProperty >> C:\PID.txt</p></td></tr> <tr> <td valign="top" width="167"> <p><strong>weight</strong></p></td> <td valign="top" width="152"> <p>The weight setting for a managed property.</p></td> <td valign="top" width="340"> <p>Any value between 0 and infinity. If the value is 0 the property is ignored. Normally the value is between 1 and 75.</p></td></tr></tbody></table></p> <p>The xml schema for a ranking model is structured in the following way: <p><rankingModel name=”string” id=”GUID” description=”string” xmlns=”<a href="http://schemas.microsoft.com/office/2009/rankingModel">http://schemas.microsoft.com/office/2009/rankingModel</a>”><br> <queryDependentFeatures><br> <queryDependentFeature pid=”PID” name=”string” weight=”weightValue” lengthNormalization=”lengthNormalizationSetting” /><br> </queryDependentFeatures><br> <queryIndependentFeatures><br> <categoryFeature pid=”PID” default=”defaultValue” name=”string”><br> <category value=”categoryValue” name=”string” weight=”weightValue” /><br> </categoryFeature><br> <languageFeature pid=”PID” name=”string” default=”defaultValue” weight=”weightValue” /><br> <queryIndependentFeature pid=”PID” name=”string” default=”defaultValue” weight=”weightValue”><br> <transformRational k=”value” /><br> <transformInvRational k=”value” /><br> <transformLinear max=”maxValue” /><br> </queryIndependentFeature><br> </queryIndependentFeatures><br></rankingModel><b></b> <p>The following link describes the different elements in the XML: <a href="http://msdn.microsoft.com/en-us/library/ee558793.aspx">http://msdn.microsoft.com/en-us/library/ee558793.aspx</a> <p><b></b> <p>So, in order to create a new ranking model, open a xml editor and use the following example: <p><b></b> <p><?xml version="1.0" encoding="utf-8"?><br><rankingModel <br>name="DemoRankingModel" <br>id="302A9E0E-F8B9-4b21-8180-C327ECCBBA94" <br>description="Demo Custom Ranking Model" <br>xmlns="<a href="http://schemas.microsoft.com/office/2009/rankingModel"">http://schemas.microsoft.com/office/2009/rankingModel"</a>> <br><queryDependentFeatures> <br><queryDependentFeature pid="56" name="Filename" weight="75" lengthNormalization="10" /> <br><queryDependentFeature pid="2" name="Title" weight="25" lengthNormalization="10" /> <br></queryDependentFeatures> <br></rankingModel> <p><b></b> <p>Next, run the following PowerShell command to upload your new custom ranking model: <br>Get-SPEnterpriseSearchServiceApplication | New-SPEnterpriseSearchRankingModel –RankingModelXML ‘{your xml pasted as a string}’ <p><code></code> <p><strong><font size="3">Using the new Ranking Model:</font></strong> <br>There are two ways of using the custom ranking model <br>1. Search logic implemented through the object model (shown in this tutorial) <br>2. Extending the Core Results Web Part <br><a href="http://msdn.microsoft.com/en-us/sp2010devtrainingcourse_extendingsharepointsearchlab_topic4#_Toc280092619">http://msdn.microsoft.com/en-us/sp2010devtrainingcourse_extendingsharepointsearchlab_topic4#_Toc280092619</a> <p>You can use the test harness described in the beginning of this tutorial to test your new ranking model. To do that, uncomment the following line and supply the GUID of your new ranking model: <p>//This is where we will later specify the custom ranking model to use. <br>fullTextSqlQuery.RankingModelId = "302A9E0E-F8B9-4b21-8180-C327ECCBBA94"; <br>//remember to replace the ID value with the GUID of your ranking model <p> <p>You will notice a change in the way your test harness return the results. <p>The following diagram shows how your code and the SharePoint Foundation will use your custom Ranking Model to provide different results: <p><a href="http://lh5.ggpht.com/_SX0lCwhJEzc/TdZ7HBdKypI/AAAAAAAAAiU/k78wXS5hlpc/s1600-h/clip_image007%5B7%5D.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image007" border="0" alt="clip_image007" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNojZFkwIQxRJfLZ5yQbQhyLpaqIRAfH65jb9lRvyjeF4NtcC-rcPM03ewOvjxIuF7z_QnRG-nki0ucgqUjZ_85twfrSb6tDVw7wr2mBqbOPKl4VQDV2h3w9QvUxOAPJZy0dK_1WN7hSI/?imgmax=800" width="588" height="376"></a> <p><strong><font size="3">Additional PowerShell Commands:</font></strong> <p><strong>List all of the Managed Properties in SharePoint Search: <br></strong>Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchMetadataManagedProperty >> C:\PID.txt <p><strong>Add a new ranking model to SharePoint : </strong><br>Get-SPEnterpriseSearchServiceApplication | New-SPEnterpriseSearchRankingModel –RankingModelXML ‘{Ranking model XML PASTED AS A STRING}’ <p><strong>List the ranking models: <br></strong>Get-SPEnterpriseSearchServiceApplication|Get-SPEnterpriseSearchRankingModel <p><strong>Delete a ranking model: </strong><br>Remove-SPEnterpriseSearchRankingModel -Identity ‘xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx’ -SearchApplication Get-SPEnterpriseSearchServiceApplication <p> <p><b></b> <p> <p>I hope that you will make full use of all the SharePoint capabilities like custom ranking models to unlock your full potential to providing world-class SharePoint solutions. <p>Enjoy ! Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com12tag:blogger.com,1999:blog-429025622434259152.post-73705707650867262982011-05-20T13:58:00.001+02:002011-05-20T14:03:23.586+02:00Upcoming Events<p>Very few things in life are more rewarding for me than to see that I have made a positive impact on the life of one or more individuals through my technical- and motivational contributions to the community. <br>This month I have been very fortunate to be invited to a number of local as well as international events. I hope to see you at the following events where I will speak on various SharePoint topics: <br></p> <p><strong><font color="#0000ff" size="4">24 May 2011 – Microsoft Dev Days - Cape Town (community slot)</font></strong><strong><font color="#0000ff" size="4"><br></font></strong><strong>Improve SharePoint Search Relevance through Custom Ranking Models<br></strong>When searching for content we want a search engine to put the most relevant content at the top of the results page. SharePoint employ different ranking models to compute what content item is more relevant than another content item. In this session we will explore how you can use PowerShell and Visual Studio to build SharePoint Custom Ranking models in order control how SharePoint determine the relevancy and order of search result items.<br>URL: <a href="http://www.microsoft.com/southafrica/devdays/">http://www.microsoft.com/southafrica/devdays/</a></p> <p><strong><font size="3"><font color="#0000ff" size="4">31 May 2011 – Information Worker Community – Cape Town</font><br></font>SharePoint 2010 Sandboxed Solutions</strong><br>In this session we will take a look at SharePoint Sandboxed solutions, understanding what they are, why they were introduced and best practices for building one. We will also advise Farm Administrators on the tools & techniques available to manage user solutions and partially trusted code in a SharePoint farm.<br>URL: <a href="http://www.informationworker.co.za">www.informationworker.co.za</a> </p> <p><strong><font color="#0000ff" size="4">25 June 2011 – SharePoint Saturday India – Online Event<br></font>Understanding the SP2010 Managed Client Object Model<br></strong>In this session we will take a look at the SharePoint2010 Managed Client Object Model. <br>We will present an overview of what the Client Side Object Model is, why it was introduced, what are the best practices for using it and lessons learned from the field.<br>URL: <a href="http://www.sharepointsaturday.org/india">www.sharepointsaturday.org/india</a> </p> <p><strong><font color="#0000ff" size="4">18 October 2011 – European SharePoint Conference – Berlin<br></font>A Developer’s mind-shift from Sp2007 to Sp2010.</strong><br>In this session we will discuss the best approach for a SharePoint 2007 developer to make the transition to SharePoint 2010 development. We will introduce new advancements in the SharePoint 2010 platform as well as how SharePoint 2010 is now integrated with Visual Studio 2010. The outcome of this session is to provide the developer with a roadmap for making the transition from SharePoint 2007 development to SharePoint 2010 development with Visual Studio 2010, SharePoint Designer 2010, PowerShell and Codeplex solutions for SharePoint 2010.<br>URL: <a href="http://www.sharepointeurope.com">http://www.sharepointeurope.com</a></p> <p>I sincerely hope to see you at the events! <br>In case you miss any of the events, please keep an eye on this blog site as I will post all my presentations in the form of detailed whitepapers.</p> <p>Enjoy! </p> Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com0tag:blogger.com,1999:blog-429025622434259152.post-41391605732135528522011-04-13T17:15:00.001+02:002011-04-13T17:18:37.745+02:00Resolve SharePoint Errors caused by SQL Express<p>Today I tested my bulk import tool as part of a data migration. The code in the custom developed tool is straight-forward and must move list items and documents from over 600 SharePoint 2007 sites into a single SharePoint 2010 site. <p>Soon after starting my tests I ran into SharePoint foundation problems. <p><b><u>Problem:</u></b> <p>Whenever the code attempts to upload a file into SharePoint I got the following error: <p><font color="#ff0000">The URL 'Document_2011/0000000zzz/Test Document.docx' is invalid. </font> <p><font color="#ff0000">It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web. Troubleshoot issues with Microsoft SharePoint Foundation.</font> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYLmgax1IkKjepCtqKczjDtmurHBud2NWqpfSlR9day68kPl6tJufyNgOuCrKN4pAvIkIeWo8nYBiDCdR76K5yJAxGFPykl7c1vcNjpMSMdOB4NZI_VuP3uwIr47LO5YzJCPj9JD15KTc/s1600-h/image%5B5%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3y-6bgsnqd3uLYYmWpuS9HqBMXmLJXA-9NxiYnh9G_T4QC8quvWrpuy2dbgyynYNoFFEJpStGGSwzfC876u4xWZNOWkVwP8j1QnGNeV6i1GcJlB9r4fdR_QlQ8_kGtarY7-2a0ZN4XEo/?imgmax=800" width="356" height="256"></a> </p> <p>I then tried to manually delete a file from the SharePoint site and received the following error: <p>The server has encountered the following error(s): <p><font color="#ff0000">ExampleFile.pdf </font> <p><font color="#ff0000">Exception from HRESULT: 0x80131904</font> <p>When I try to delete the entire document library I receive the following error: <p><font color="#ff0000">Exception from HRESULT: 0x80131904 </font> <p><font color="#ff0000">Troubleshoot issues with Microsoft SharePoint Foundation.</font> <p><b><u>Investigation:</u></b> <p>I investigated the SharePoint content database. <p>In Central Admin, go to Application Management and then to Manage Content Databases. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsG4ys6Ei4_E3UG-G3C4jWhpdijIR3pA1M1zYMYu_EfhNehVaQaQRpSgw6b2N0zY1K6U6dXhqSJZr0fv3QfKXoJA1QbJtHhI_-GLzOx_W8c39PzqngSbvxVp65UmGjGkPNbX18zH7lbhc/s1600-h/image%5B9%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_SX0lCwhJEzc/TaW9wtO-DcI/AAAAAAAAAgQ/t4TYTEqYPu4/image_thumb%5B5%5D.png?imgmax=800" width="420" height="165"></a></p> <p>You can select the web application and view the details of the associated content database.</p> <p><a href="http://lh3.ggpht.com/_SX0lCwhJEzc/TaW9w9p6ugI/AAAAAAAAAgU/4spNN9DFLgc/s1600-h/image%5B43%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_SX0lCwhJEzc/TaW9xiKAjuI/AAAAAAAAAgY/Jbk4eFtCVq4/image_thumb%5B17%5D.png?imgmax=800" width="274" height="160"></a> </p> <p>I then logged into SQL Server Management Studio and confirmed that the content database ran out of space. As you can see from the screenshot below, the database size is 4138.19 MB and there is only 0.13 MB free space. (ensure to log into the correct instance of SQL in order to see the content databases)</p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-m-v-pfr_D84CgDSWg3Ra94JvcTOUcZmGCKBYzwsopiZhrts3aQ9VtK-7onXendyBjmmnSepjf22migodYcn_rFVcMGeLGaSrqbAi3bMsA_zURAJhb2_zyHoXlriaQqJggNmlvT518jQ/s1600-h/image%5B44%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJuhd9e345CJHOK3ncaXiQEZERskdbHEHMVusylpaaxYe3l3cn4cfJ1oogf3ICK4J6H1WGsovtaW7X81pIxF6Oi2rZUXPccq4g0YPmj6Cdh5vsNO5JbQyB1WLNKQDjP-imxF83WKehQXY/?imgmax=800" width="337" height="153"></a> <p><b><u>Cause:</u></b> <p><b><u></u></b> <p>When SharePoint 2010 is installed the user can select to perform a ‘Basic’ or default installation. <p>Selecting a ‘Basic’ installation is a big mistake, but unfortunately guys who are new to SharePoint might not be aware of the pitfalls. <p>When you installed SharePoint 2007 as basic, the installation used the Windows Internal Database, a version of SQL Express with no size limit, but in SharePoint 2010 the installation will be done on SQL Express which has a 4GB size limit. <p>SQL Express 2008 R2 has a 10GB size limit, but it might still not be enough. <p>This was exactly my problem –SharePoint was installed as a ‘Basic’ installation on a test environment and I was trying to upload a large number of files – around 5.3GB in total size. Once I reached the limit of 4GB SharePoint could not perform any operations on the database which requires more space. <p>Remember that even if you try to delete items from SharePoint, they are only moved to the recycle-bin so the used database space does not become available immediately. <p><b><u>Solution:</u></b> <p>There are two ways to solve this: <p>1-You can either upgrade from SQL Express to SQL Server, <p>or <p>2- Implement EBS (External Blob Store - move the BLOB items out of the database onto a file system. For more information on this please see <a href="http://msdn.microsoft.com/en-us/library/bb802812.aspx">http://msdn.microsoft.com/en-us/library/bb802812.aspx</a> ) <p>I decided to go with option #1-Upgrade my SQL Instance from SQL Express to SQL Server 2008 R2. The better architecture would be to go with EBS but I wanted to explore the database upgrade and do the EBS later. <p><b><u>Upgrade Steps:</u></b> <p>1-Close SharePoint and Close SQL Server Management Studio. <p>2-Open Command Prompt and run the following command from the location where the SQL Server installation files are available to start the installation (upgrade) of SQL Server R2. <p><strong><font color="#000080">Setup.exe SKUUPGRADE=1</font></strong></p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMG_VVetBU55AAnedyfo_i-79XMi_DkYnuU913I66b54GwO-0c2Y6Nn0sVAtgEv88tZnb9lDOBDyrGs-w_FrpMBSCZa7-HtkJnBoWBxFfsEP4qtCntl8tSU1TZSsKTZoTJX7TLtzWEafg/s1600-h/image%5B45%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhutLCXpF2mycuAIdAEhOIXqz1r7JqHk6Dg3FDrq9MJD_MKcQ26d1WI-rI7gqhERtWPQ6oznJ-rwCKjzpR8OkVdNajhBOvufNTLrWjyXmmAnuD-eT8250m9FZALXuSgeT0nHYVKCqn1QWY/?imgmax=800" width="415" height="118"></a> <p></p> <p></p> <p></p> <p></p> <p>3-Proceed through the installation wizard and on the Installation window click on <b>‘Upgrade from SQL Server 2000, SQL Server 2005 or SQL Server 2008.</b> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigURaKrdE5srsvzvhPLz4YhWAJFS0QDy1iq0et8j9AHxshJrqK8Xd267ZCSsYI764oIx53gkWPyRsoGn62eEbIHS7wvwR7EG_2jURorD82xAaQ-KAp98YOtISNiyW50JztkeaGuKrDiyM/s1600-h/image%5B50%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhonOQUcOBMK4RLY-RDpQMc2OB5rMaIc3borLd6b4qJ94IuBx3a5rKtvOic897kbrG19Gm0OwNq0UTz4k6qLj_OpKBoVyncvLFIqhvPTw0vP0PtmgPjixmrQ2cfELXk5g7sUOfFrd_xADk/?imgmax=800" width="369" height="282"></a> </p> <p>4-Proceed through the wizard until you get to the ‘<b>Select Instance</b>’ page. <p>Remember when we inspected our database details in Central Admin we were able to see the SQL instance:</p><a href="http://lh6.ggpht.com/_SX0lCwhJEzc/TaW917IJSPI/AAAAAAAAAg0/r4SL_FL61HI/s1600-h/image%5B47%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_SX0lCwhJEzc/TaW92gp-oGI/AAAAAAAAAg4/jZDiaM-Ddz0/image_thumb%5B21%5D.png?imgmax=800" width="307" height="82"></a> <p></p> <p>5-Now, in the SQL Upgrade wizard you have to select the same instance. You can see from the screenshot below that my “SHAREPOINT” instance was originally installed as ‘Express’ so this is the one which I have to select to be upgraded to SQL Server 2008 R2. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHSxfdTl9RbFRWljtJUBh2XrwbwOYkmDPsywSLibc4EZVv1OQSALcSFsGJ1SP6TRoRBEaK9srYsdu3yIlWdXFiXVnYWe1vT1KNJJwgASJfatd-mvzwXXd_9MIpRg6yCkCQqo5aLCfUyZg/s1600-h/image%5B55%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkXyIeQei1m_2GJNdPrxAIcDYzp1R-LVB5xESjYBQtFovztvttUgDKC3CfNpWRSUq0hQP4SEh55qQdUSM-cRRuEOEzcaqRPeLuaZkO7ypS2q5G7cIN6iPjXxtV2oLzWLrsMQbBnCfpwMo/?imgmax=800" width="379" height="295"></a> </p> <p>6-Click on Next and continue through the wizard….When you get to the “Instance Configuration” page pay careful attention to ensure that all the details are correct.</p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioMC7D4Hn8U62e9Qljh-T7N93D1sOBQxz9dduVfg1O8gbx4nQXvX5LU0bKl0R1GDxL5t1LUtinBov3Bo-0BYn9BJZhwXIH25McLrmmrZ_nVTFe2I5UumpIkXn13fkrnVJr1KKybyABTLw/s1600-h/image%5B52%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_SX0lCwhJEzc/TaW96AgN3oI/AAAAAAAAAhI/9mtbcNeBLRw/image_thumb%5B26%5D.png?imgmax=800" width="385" height="295"></a> <p></p> <p>8-Click on Next and proceed through all the pages to complete the all the installation wizard steps. <p>9-Once completed review the results to confirm that the upgrade was successful. <p> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcEZm3wwgrLacXouO49eE6MNGeqfjxpF_Av_p7AWcoFu4uR2-1e002vPVXa95v6s0NY3jsTxP1nloJrrOEd46IT-YkBt0TbS_N_3zpGSdc3NqGin1mmX3Dl1zMpESNFMiJpZKlCvm_k14/s1600-h/image%5B57%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_SX0lCwhJEzc/TaW97wQXlkI/AAAAAAAAAhQ/g5LefTnh914/image_thumb%5B31%5D.png?imgmax=800" width="396" height="303"></a> </p> <p>10-After this perform an IISReset. <p><u><strong>Verify Success:</strong></u> <p>I viewed the properties of my upgraded database and immediately noticed that the space available was increased from 0.13MB to 1.02MB. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtm1UPW-guPlvZ-lb3XMTh6dA8XKrLkGU48oVh1LbPZryXjbQa8oXjng1B6lApwQ0Z9SladZ0nFSn8xvg8DMV_w4hkoil_BqEPtGsJzKgOmdxP64JlTws5byAReMvnR2eUh3FabKjBRdw/s1600-h/image%5B60%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2UV7eVXVybXfs6hrVJr0zQRq1zxkCr4t82_vn9dChoi9xabhLnmcDHVZTGm5weGqabyeRK5XxApnW_2MhOEqaSMTs2m9xts0XFRl8riR_FFopp6Dhw2FLyd3bs-W2i8ylbjiMe4k_Rts/?imgmax=800" width="377" height="201"></a></p> <p>Also, after this I was able to add more content to SharePoint and grow the database size beyond 4GB.. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEioutWRrGh0JammAJRN2jEnUsR6Hlo_eTnKSX6CFs5_FhG47N1vBXmv6rE4-FfG-LBU-Vje7trBskv5uPOSZIOEl9Y-kvgZVzCtv4jCPM3xSJKKyt0HBeH8_H7e5WhhwveQ-BTllrpP4/s1600-h/image%5B61%5D.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLmTVIV-knBV9P1XUKmYXhXIISmzoxllryCxT_W0WI0IORhyADKJJThIV2PGOD9FuAlH4HaKjQk1orZCJwS1QcGDwT0CgjZ9fZxmq8eHeAnbg2Rh6TfTGlOzxmrvm5zCSONQowCoeT6tU/?imgmax=800" width="377" height="204"></a> <p>Enjoy!! <p>Thanks to Todd Klindt - <a href="http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=55"><font color="#000080">http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=55</font></a> for his contributions. Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com17tag:blogger.com,1999:blog-429025622434259152.post-10143366914066810202011-03-17T13:15:00.002+02:002011-03-17T15:37:45.290+02:00Import and Publish Nintex Workflows programmaticallyI recently developed a SharePoint solution which requires that 3 Nintex 2010 workflows are published on 13 document libraries in 22 SharePoint sites. I developed the Nintex workflows on a single library in one site and gave it to the test team to perform quality assurance. Now that I know the workflows are working well, we are ready to export them and upload and publish them to a much larger test environment. This will require that we import and publish 3 workflows x 13 libraries x 22 sites …thus a repetitive 858 manual tasks… there is no way that we will do this manually, so I took a little time to develop a tool which will programmatically import and publish workflows. <br />
I found that it really is easy to utilise the Nintex web services to manage workflows. <br />
In this tutorial I will give you a high level overview of how to use code to upload / import .nwf files to a target SharePoint site thereby automating the process as much as possible. This approach will help you to move workflows between development-, test- and production environments. <br />
<b>What we want to achieve:</b> <br />
I developed a simple tool which allows you to select one or more exported workflow files as source and then specify the target environment to which the workflows must be imported and published. <br />
<a href="http://lh5.ggpht.com/_SX0lCwhJEzc/TYHtI6NANAI/AAAAAAAAAfs/pcBQV3YK1Ow/s1600-h/image%5B29%5D.png"><img alt="image" border="0" height="344" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOlr8tAVsyM1Wm0F4W3j4SG3iDjpFOaGdHsa0Xyah17jocPM64UOxRZmvkU9NYydusR9-bi5xqlT4AruzEm5L9zUumCimBUsyEd_yue_VY8OnVr0Xzlm3hiU642MbNmSa1qydYkQMMNQY/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="569" /></a> <br />
<b><br />
</b><br />
<b></b><br />
<b>You need the following:</b> <br />
1. A few working Nintex workflows exported to local .nwf files. <br />
2. A target SharePoint site with document libraries or lists which you can use as target to import and publish the workflows to. <br />
3. Nintex Web Services must be accessible (installed with Nintex). <br />
<b>Preparation:</b> <br />
1. <b>.NWF Files:</b> To create a few workflows to test with I created a few really simple workflows like the one below which just update a single field on the list / library. I then saved the workflow, published it and tested it. After I have confirmation that the workflow works well I proceeded to export the workflow as a local .nwf file. Remember that this must be done in a SharePoint site which is different than your target site or you have to delete the workflows from the site before you test the import code. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZD7YVQX1iMucUYPMLyqb1IhG4EcLdr5Jp-kMVIeoyhnkwuOSyKOMUkSV3AhZYpVHnUl65vaKRv6BrAIZs2OJPz_qo1dASE8gBQ5LkTkO_X6Z1i4iWN6ctFHN3K-2GWrAl_vE5vyoPfDY/s1600-h/image%5B8%5D.png"><img alt="image" border="0" height="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeo3mJtLLt8YEfEmOV82BDa15K2-KRZX0Qk2t_yyYuAGL_v1jGViSbz3BN2nVjZaiU8Q6sRHgG0SQr9XQ7El1jS2I1SqZ4m6RIS5gRrIIdH8qvqBABtIkKirC3w85P0CO6DlKpz_7K22c/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="397" /></a> <br />
<b></b><br />
<b></b><br />
<b><br />
</b><br />
<b></b><br />
<b>2. </b><b>Target SharePoint site: </b>Your target SharePoint site must have Nintex Workflow installed and configured. You can go to your test target library and from the ribbon verify that you have access to create or manage Nintex workflows: <br />
<a href="http://lh6.ggpht.com/_SX0lCwhJEzc/TYHtMwkRa0I/AAAAAAAAAfE/PXg41VHygYc/s1600-h/image%5B13%5D.png"><img alt="image" border="0" height="176" src="http://lh4.ggpht.com/_SX0lCwhJEzc/TYHtOXNJN8I/AAAAAAAAAfI/ASlB0PIh7n4/image_thumb%5B7%5D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="238" /></a> <br />
<b></b><br />
<b></b><br />
<b>3. </b><b>Nintex Web Services: </b>You should be able to browse to the Nintex Workflow web services. <b></b><br />
These web services are included as part of the Nintex Workflow out of the box installation. <br />
The URL will be <SP Web App URL></_vti_bin/nintexworkflow/workflow.asmx><b></b> <br />
Example: My target site is in the following web application <a href="http://ltp-21:17819/">http://ltp-21:17819/</a> so the URL which I will use to access the Nintex Workflow web services will be: <br />
<a href="http://ltp-21:17819/_vti_bin/nintexworkflow/workflow.asmx">http://ltp-21:17819/_vti_bin/nintexworkflow/workflow.asmx</a> <br />
You should be able to use Internet Explorer to navigate to the web service URL. <br />
<b></b><br />
<b>Let’s Write the Code:</b> <br />
Please note that in order to simplify the tutorial I will only show the code which is required to import and publish the workflows. <br />
I therefore assume that you will be able to develop the additional code which you will need to make a tool similar to the screenshot at the beginning of this post fully functional. If you are interested in any other bits of the code for the complete tool please leave a comment and I will gladly send it to you. <br />
1. Create a new Visual Studio Windows Forms Application. <br />
2. Because we target SharePoint 2010 remember to set your platform target to 64 bit: <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuo2LnmuKOTAZQ59OJg1qhdaUJgdJZbLd2dHTff_oC7PsC4XnYf5JgXhD5Kivw_x4iop9aYTUw-If_IYv_cG8wHhDxo80fX3w9_7p_pWYar0yQIcaAuB_f4XmRWhyISg-D9mv7xeMzwI8/s1600-h/image%5B17%5D.png"><img alt="image" border="0" height="153" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjg_GFLncPEYEMmldsK-zGcx7CWDjpwp4M7iTuw3qL3kwoLez5s7NHxsdy3zaK7vtWnef4PQ3WCV5RiaKoW6GVe_whdyClRNK_mfQgyP1BR4Sh9i91dmUGN13gn0US2SqoKMio_kk5gu6c/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="377" /></a> <br />
3. Add a web service reference to the Nintex Workflow web service: <br />
Remember the URL of the Nintex Workflow web service is in the form <b></b><br />
<SP Web App URL></_vti_bin/nintexworkflow/workflow.asmx><b></b> <br />
Example: My target site is in the following web application <a href="http://ltp-21:17819/">http://ltp-21:17819/</a> so the URL which I will use to access the Nintex Workflow web services will be: <br />
<a href="http://ltp-21:17819/_vti_bin/nintexworkflow/workflow.asmx">http://ltp-21:17819/_vti_bin/nintexworkflow/workflow.asmx</a> <br />
I used NintexWorkflowService as the web reference name <br />
<a href="http://lh3.ggpht.com/_SX0lCwhJEzc/TYHtRMoZF4I/AAAAAAAAAf0/PZGdJmdpU48/s1600-h/image%5B30%5D.png"><img alt="image" border="0" height="381" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4Q2E064wjZuszpXF5bT_krw-wtDOMNUxhikDndCEaiCp46TSrXRdhspHZG4dWpcuDRZNDW4Ms_lmUwR0axCE8aJaSOmsHJvcaK8jLwFOVeb8Re1n-FN2y4Q95qZbdY8tT1dHY5FOCoRs/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="534" /></a> <br />
4. Add a new button named cmdImportWorkflow onto Form1: <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDJQxBBRHSlysCmDkRUA_ZPejpAZx7PtT5Gi5mkpv6Y69i9ojyGXG4wrF8bBFd0toNvgpS5iRco1x4Mldcnps3WJCy2iAPnVltFjyy-8I0dY9-ouBuPzMfPLTjsJKeoLxXbjGoQECgFro/s1600-h/image%5B24%5D.png"><img alt="image" border="0" height="210" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7k6xPurjo1V-atgnGNJAS0oiEE-ppAbOrs-DTiZPmmcvUGttMQOX0HMI5NZeCV1G10gxzyulmSlfIbOEr4G-wCmkW1aG7Hkz9vQSQOzSZDuv5vIyW27bBYNl9m8GIaSqAabHPcLxVce8/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="228" /></a> <br />
5. Add the following code to the button click event: <br />
<blockquote><span style="color: #0000a0;">try<br />
{<br />
NintexWorkflowService.NintexWorkflowWS objWFService = new NintexWorkflowService.NintexWorkflowWS(); </span></blockquote><blockquote><span style="color: #0000a0;">objWFService.Url = "</span><a href="http://ltp-21:17819/MyNintexSite/_vti_bin/nintexworkflow/workflow.asmx%22;"><span style="color: #0000a0;">http://ltp-21:17819/MyNintexSite/_vti_bin/nintexworkflow/workflow.asmx";</span></a></blockquote><blockquote><span style="color: #0000a0;">objWFService.Credentials = System.Net.CredentialCache.DefaultCredentials; </span></blockquote><blockquote><span style="color: #0000a0;">byte[] arrWorkflowFile = System.IO.File.ReadAllBytes(@"E:\WorkflowsToImport\UpdateTitlewithTime.nwf"); </span></blockquote><blockquote><span style="color: #0000a0;">objWFService.PublishFromNWF(arrWorkflowFile, "MyDocs", "My Imported Workflow", true); </span></blockquote><blockquote><span style="color: #0000a0;">}<br />
catch (Exception exception)<br />
{<br />
MessageBox.Show("An error occured while trying to publish the workflows: " + exception.Message);<br />
} </span></blockquote><blockquote><span style="color: #0000a0;">MessageBox.Show("Done");</span></blockquote><b>Let’s Analyse the code:</b> <br />
1. Instantiate the Nintex Workflows web method: <br />
<blockquote><span style="color: #0000a0;">NintexWorkflowService.NintexWorkflowWS objWFService = new NintexWorkflowService.NintexWorkflowWS();<b></b></span></blockquote>2. Ensure the web method will execute against the correct target URL: <br />
<blockquote><span style="color: #0000a0;">objWFService.Url = "http://ltp-21:17819/MyNintexSite/_vti_bin/nintexworkflow/workflow.asmx";</span></blockquote><blockquote>This URL must be the full URL to the target SharePoint site followed by “/_vti_bin/nintexworkflow/workflow.asmx”. </blockquote><blockquote>Please ensure that you replace the first part of the URL with that of your target environment.</blockquote>3. Set the credentials for the web service: <br />
<blockquote><span style="color: #0000a0;">objWFService.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></blockquote>4. Read the Nintex workflow file (.nwf) into a byte array: <br />
<blockquote><span style="color: #0000a0;">byte[] arrWorkflowFile = System.IO.File.ReadAllBytes(@"E:\WorkflowsToImport\UpdateTitlewithTime.nwf");</span></blockquote><blockquote>This is the workflow which we exported earlier to a local file.</blockquote>5. Call the web method to import and publish the workflow file. <br />
<blockquote><span style="color: #0000a0;">objWFService.PublishFromNWF(arrWorkflowFile, "MyDocs", "My Imported Workflow", true);</span></blockquote><blockquote>The parameters are:</blockquote><blockquote><span style="color: #0000a0;">1. <b>arrWorkflowFile:</b> Byte Array of the workflow file to be imported.</span></blockquote><blockquote><span style="color: #0000a0;">2. <b>listName:</b> The name of the target list / library.</span></blockquote><blockquote><span style="color: #0000a0;">3. <b>workflowName:</b> The name which will be assigned to the new imported workflow.</span></blockquote><blockquote><span style="color: #0000a0;"><b>4. </b><b>saveIfCannotPublish: </b>Flag to indicate whether the workflow must be saved if it cannot be published.<b></b></span></blockquote><b></b><br />
<b>Verify Success:</b> <br />
Run the code and step through each line to ensure there are no exceptions. <br />
After successful execution open the target SharePoint site and the target document library / list. <br />
Go to Manage Nintex Workflows and verify that the workflow was successfully imported and published – you should see the new published workflow. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgolwkSaP62DNTUaXoE8LHJoBVdKVPKxAnUJujfEjQ6qcWfIHxx-8G51MAqu8OcmRg3KoTvFvOVcEXRJpKfM2Or7BGzPAagxoTTKuowX7R0pDl-ZeokhZvXBijVAv3WqcGiDqbOGmCijBA/s1600-h/image%5B31%5D.png"><img alt="image" border="0" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG934UBJPE0fBRj8nvR5IRy43yrHZlfJzQXe0vsC8e1GfUzdBtuwURxwDXAxG04wUeAxXR-oR8JmaIi4brYQOsX5okGCz53OLpgLZva52KfYPDltRHD7GqV5hShB4TfnSCo4APhyphenhyphenlyDsU/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="576" /></a> <br />
<b>Conclusion:</b> <br />
As you can see from the sample code it is really easy to automate the import and publishing of Nintex 2010 workflows to SharePoint 2010. You might come across a few exceptions if your environment does not allow certain workflow actions or if dependencies (like list or field lookups in workflows) are not in place in the target environment. <br />
You can now use the very basic sample code to develop a tool like the one I illustrate at the top of this post to automate workflow upload & publishing and hopefully save your system administrator hours of manual configuration. <br />
Enjoy !!Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com14tag:blogger.com,1999:blog-429025622434259152.post-88295098739472111312011-02-11T09:58:00.002+02:002011-03-17T15:38:32.280+02:00Nintex Workflow 2010 ‘Task Reminder’ Bug & Fix<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">This morning I came across the following error while trying to publish a Nintex 2010 workflow which contains a ‘Task Reminder’ workflow action.</span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;"><strong>Background:</strong></span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">I have a SharePoint 2010 MOSS environment. </span></span></span><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">I create a new Nintex 2010 Workflow which I can save and publish without problems.</span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">Then I add a ‘Task Reminder’ action</span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgQmYmktFsmiZcGtjVhd4ARYfJlPeno08YLl6_h-eQRNxepisd0nV9z0CCWz7Lam8QCQE3lvQJG-aJLLXwmF49qiLr_0UDIJZir4ThOUHmy1okaXdKMh814GwlWdO_a2Nb21c2s9SMTgg/s1600-h/image%5B5%5D.png"><img alt="image" border="0" height="84" src="http://lh3.ggpht.com/_SX0lCwhJEzc/TVTsE5bLpaI/AAAAAAAAAec/3O9oXyi7hP4/image_thumb%5B1%5D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="156" /></a> </div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;"><span style="mso-fareast-language: en-gb; mso-no-proof: yes;"><shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="Picture_x0020_2" o:spid="_x0000_i1027" style="height: 71.25pt; mso-wrap-style: square; visibility: visible; width: 129.75pt;" type="#_x0000_t75"><imagedata o:title="" src="file:///C:\Users\jolivier\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"></imagedata></shape></span></span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"></div><br />
<br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">And when I publish the workflow I get the following error:</span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmTob6RbxWmdcJlKLUYyMGRxhZTEHHtMxd3x53GkTMYbPdVq-acSjsApWKx0e4DZkx4uTSa2U6yszOI1eU1NNvYJPfgSguDsAxhEKWuW_lDoT0DMBnO56Smng5aGf0NCGwweCQv0fwulk/s1600-h/image%5B9%5D.png"><img alt="image" border="0" height="164" src="http://lh6.ggpht.com/_SX0lCwhJEzc/TVTsGeKoO-I/AAAAAAAAAek/fVsC-QU5rrc/image_thumb%5B3%5D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="356" /></a> </div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><strong><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">Cause:</span></span></span></strong></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span style="color: black; font-family: Calibri; font-size: small;">For a type to be used within the workflow, it must be registered as an Authorized Type in the web.config file. All of the Nintex workflow actions and custom types are registered as authorized types.<br />
Some of the workflow actions have a property of a type that inherits from a generic list, that is List<T>. List<T> is a basic system type provided in .NET. <br />
</span><span style="color: black; font-family: Calibri; font-size: small;">With SharePoint 2010, List<T> is no longer authorized. Workflow actions that use a type that inherits from List<T> no longer run or publish.<br />
The SharePoint web service to validate workflows returns the following error when publishing:<br />
<span style="color: #c10000; font-size: x-small;"><Error><CompilerError Line="0" Column="0" Text="Type System.Collections.Generic.List`1, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is not marked as authorized in the application configuration file." /></Error></span><br />
<br />
<strong><span style="font-family: "Calibri", "sans-serif"; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-hansi-theme-font: minor-latin;">Work around:</span></strong></span></span><span style="font-size: 10pt;"><span style="font-size: small;"><span style="font-family: Calibri;"><span style="color: black;">Add the following to the web.config of the SharePoint web application on which you want to publish the workflow.</span></span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span style="color: navy; font-family: Calibri;"><authorizedType Assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.Collections.Generic" TypeName="List`1" Authorized="True" /></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><a href="" name="_MailAutoSig"></a><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="mso-bookmark: _mailautosig;"><span style="color: black;"><span style="font-size: small;"><span style="font-family: Calibri;">Save the web.config and return to SharePoint and now you will be able to successfully publish the same workflow (containing the Task Reminder):</span></span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0xlOuS2l31cP0Z9nHBD7CuwlvNG18_9fl7o8z04_NyMBxfcb_TNya08lztDhRNd-ZvPA0RD7uQqAWHvdiAJ6esdPsbdhzUlsLWReufz_xDxRZdXlZoRHGvMtC85ZI52afEzdSjKHvFbM/s1600-h/image%5B2%5D.png"><img alt="image" border="0" height="120" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7CtoGFfxPaMfN7X-t7F-HQNXkM8Pr_YamPyprqYvUdwXSlEFfv1XuXQlDL06T8yXgsAYYMMFRgzEGdfRkw4cmjMPfdfDoXKML8gG4A060zMOGAHOTMocmGrrnNN2paltUeitFjaY6nn8/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="244" /></a> <span style="mso-bookmark: _mailautosig;"> </span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="mso-bookmark: _mailautosig;"><span style="color: black;"><span style="font-size: small;"><span style="font-family: Calibri;">Enjoy !</span></span></span></span></div><div class="MsoNormal" style="margin: 0cm 0cm 0pt;"><br />
</div><span style="color: black; font-family: Calibri; font-size: small;"></span><br />
<div class="MsoNormal" style="margin: 0cm 0cm 0pt;">Also refer to: <a href="http://connect.nintex.com/forums/thread/239.aspx" title="http://connect.nintex.com/forums/thread/239.aspx">http://connect.nintex.com/forums/thread/239.aspx</a></div></div></div>Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com105tag:blogger.com,1999:blog-429025622434259152.post-24290063619792254382011-02-03T16:51:00.004+02:002011-03-17T16:12:36.991+02:00SharePoint 2010 Incoming e-mail Settings on Windows 7Recently I needed to enable a SharePoint 2010 document library to accept incoming emails and then use the data from the body of the email to update list values. <br />
It is really easy to configure SharePoint 2010 for incoming email and to enable a specific document library to receive emails. <br />
You will find a few good tutorials on the web to help you achive this. <br />
One of the very first things which you need to do is to install and configure a SMTP service on your SP2010 web front-end server. That is exactly where I ran into problems as my SP2010 web front end server is running on Windows 7. <br />
Unfortunately Windows 7 does not ship with SMTP Service and almost all the documentation showing how to configure your SP2010 WFE for incoming mail focus on Windows 2008 server. <br />
Many thanks to Wesley Bakker for the clear and helpful instructions which he posted at <a href="http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx">http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx</a> <br />
This short tutorial will illustrate how I managed to get my SharePoint 2010 incoming email configured on my Windows 7 web front-end server. <br />
1. <strong>Download hMailServer</strong> from <a href="http://www.hmailserver.com/">http://www.hmailserver.com/</a> <br />
2. <strong>Install hMailServer</strong> and create a new Administrator password when prompted. <br />
3. <strong>Configure hMailServer</strong> in the following way: <br />
<blockquote>(If I do not specify a setting to be changed then accept the default) <br />
<ul><li>After the install completed, add a new domain. You can use anything.</li>
<li>In the new hMailServer domain create two new email accounts </li>
</ul></blockquote><blockquote><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjz4L3zhLb0EMJ2r3JMgJbC_P-Xosl3YvOZ3lWzkhJ0cdJhB9ob9E3dEPZAqAF8lg4Vd-h1RF76WYb_S01wu88i-ZZF6XOFX1Wc1zFNhjKmJHoMJRt76i2MUZGtNG1zB0LIGOpJ5pLX6G0/s1600-h/clip_image0024.jpg"><img alt="clip_image002" border="0" height="127" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtcH4cU0Ts8-2OYnD6E0Wc0PlTRDgpBK85R_KuYRVJ_VQxnB9M8EAKyD-JNAKXlud9AUUgLp2_iy4eSpF718ikXGglbsDdMOAdT-1hLIv80Zu_83oXI-W6zrpD0my5AoF5W6yPMt7ibfs/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image002" width="380" /></a> </blockquote><ul><li>Expand Settings and click on SMTP. Set the ‘Local host name’ to your local machine name. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhplsSW451p2Ux3PXi8E1QevJ-sJnbfU9QdXKxSg3W0cmu4yM5bgq_yrIWFouFf9ln6xqgY8YV_p1QpZc3vvoBRrm687aYwgpQDDM4s8zzDSatteBBzVJylVvJEYE7sLyc05yxHKq3uX-M/s1600-h/clip_image0044.jpg"><img alt="clip_image004" border="0" height="195" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgPRJ8w1zHQwDY11vQloD9LfNAQC0RsXa_bmKFQd9Y9l2gHG1ukdp3lahdwKiLxEXiTAjOMGPk4LHgIUPJ-zklo3JV7lQecdV_pZtf1HbrqxG9nGa1DmvcnAB9Sw_DnGdd4C20yA24UPk/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image004" width="392" /></a> <br />
<ul><li>Expand ‘Advanced’ and then expand ‘IP Ranges’ and click on ‘Localhost’. I changed the Name, Lower IP, Upper IP values and I removed the requirement for SMTP authentication.</li>
</ul><blockquote><div align="center"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSIpiaPxFmbn3AUxytGTTGgLgMV1iabwqjoj16C05M0q8RGUDSgeLZAScnUVNDhi9k753FT3kNQMPmkNXW3iTraQItjv83Ir4r_ao6fLnDWIGnWOtTgrl0lQUPC_DJGl__XzL5CV9lTuQ/s1600-h/clip_image0064.jpg"><img alt="clip_image006" border="0" height="256" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWUWGtKGtvTUMIjto8FU3juIS6A6vZrAXGyV7bLcVRH53mgkaYDb8szdWZOj7mjWOPq305xzLodauFCSR7TPHCqjUBxtaYpxYgzIhjHXCBxdtaKXsoAyk07cjFNHSEqh8qUF4PhBgXhmE/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="clip_image006" width="400" /></a> </div></blockquote><ul><li>Because hMailServer does not have an email drop folder by default, you have to create a folder structure to use as a drop folder. I created the following folder structure to use as my drop folder: C:\Program Files (x86)\hMailServer\Data\JohanSPSDev.local\Dropfolder\</li>
<li>Microsoft SMTP server adds header information to emails which hMailServer does not do, so if the information is missing SharePoint will not accept the emails into the library. So in order to prevent this you need to add a script to hMailServer to include the header information into the emails before there are dropped into the drop folder for SharePoint.</li>
<li>This process is very clearly explained by Wesley Bakker in his post: <a href="http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx">http://weblogs.asp.net/wesleybakker/archive/2010/08/09/configure-hmailserver-for-sharepoint.aspx</a></li>
</ul><ul><ul></ul><ul></ul><li>In hMailServer expand ‘Advanced’ and then click on ‘Scripts’. </li>
<li>Enable Scripts and click on Show Scripts. Open the existing script file in notepad and add the following text. </li>
<li>Ensure to change the drop folder path to your own configuration. </li>
<li>After you made the changes save the file and close it. </li>
<li>Back in hMailServer click on ‘Check syntax’ and then on ‘Reload scripts’. </li>
</ul><a href="http://lh5.ggpht.com/_SX0lCwhJEzc/TUrAj5fPCRI/AAAAAAAAAdA/5E1zyIeN1OM/s1600-h/clip_image0084.jpg"><img alt="clip_image008" border="0" height="321" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrtSdfDSRBHAM4GvNvfUwueFx9zVKmFwhd6BPJR-wDneHZl5RBmxOgSfPvdfLBDZ7TZZ-LH94kp4MMZycpu4u1xlscVTBUHHMUvbeyTtejIl0Fi9cOBfSIHTnUtRgV1Wo0n3CYdBJHcsY/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image008" width="382" /></a><br />
<strong>4. Test your SMTP Service:</strong><br />
<ul><li>Now our hMailServer should be up and running and we are ready to test whether we can send and receive email… because I also have a corporate email account and I have Outlook installed the easiest for me was to create a POP account in Outlook and point it to my new domain. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOIfzNV0iKl06t05gP4CkIzvLlu0QkH9DCSPtDCJnW4OTpEchzom0L062FiPxWLsEiG_BqC97hAQpQeSBXleKR1_D0CBWVPhB4SNIJzkR5yyqTBn_LNmzvZ7xcMVvzzjAgClTx5PASaVQ/s1600-h/clip_image0104.jpg"><img alt="clip_image010" border="0" height="275" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZRwhyHCVDX08orVF_1PmkRu4Ppv8g8VYRhJ1NByxux_85uJ0wU_QxLGjeq8qM3zg-KDr4627WsX1TeYe1nVgpPlk8gMiliW1elFTZE9EAELlMjWaWSNcBRsUADVdsWY9U7Ngbt8oUYRs/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image010" width="388" /></a> <br />
<ul><li>The important thing here is to use an IP address of your local machine instead of using the word localhost or even your pc name. I tried my pc name as well as localhost but when I tested the account settings it kept failing… I only got it to work after I provided the IP address. </li>
<li>After I finished configuration of my POP3 account in Outlook I received the following test email in my inbox as confirmation that my SMTP service is working fine </li>
</ul><a href="http://lh6.ggpht.com/_SX0lCwhJEzc/TUrAodF2FnI/AAAAAAAAAdQ/kB3H_VtM3_s/s1600-h/clip_image0124.jpg"><img alt="clip_image012" border="0" height="155" src="http://lh6.ggpht.com/_SX0lCwhJEzc/TUrAo0Xgq_I/AAAAAAAAAdU/WSsEQktRyKQ/clip_image012_thumb1.jpg?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image012" width="390" /></a> <br />
<ul><li>So now that our SMTP Service is working the next step is to configure SharePoint. </li>
<li>Open Central Administration and go to System Settings. </li>
<li>Click on ‘Configure incoming e-mail settings </li>
</ul><a href="https://lh5.googleusercontent.com/_SX0lCwhJEzc/TUrApiAci7I/AAAAAAAAAdY/2x9ScdWYehU/s1600-h/clip_image0144.jpg"><img alt="clip_image014" border="0" height="197" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8RV3XsuCnibPkfnwdOgIV23lqcIKty_d8cOoI-4astMS8S21K7JvzI7D9qi-ZPwX6QYD8ulHmmLe4fPrxKPNH3nQwTIj7_UDhfKAoG_mhrVQf5mf7TLI0aAIFBZvgTOB5FEcWJ3fPQqY/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image014" width="393" /></a> <br />
<ul><li>Set ‘Enable sites on this server to receive e-mail’ to ‘Yes’ </li>
<li>Ensure that you change the e-mail server to match that of the new domain which you created in hMailServer and specify the drop folder which you manually created earlier. </li>
<li>Click on OK to save your settings. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibHVfDdYlJXw0aL201ckLS_7W-EfFsRQY0cZgv9Uag7KqS635grhV7JVawledTz63Nyie69PT807Rf0SvfHdmEiutaG1cI9j9CSQQHpLbCmRDO1-TPnxW16PI758j-EGUDQVMMFBnsdvo/s1600-h/clip_image0164.jpg"><img alt="clip_image016" border="0" height="249" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_n0ZX5hwVfIGySq3lasYx3O9a0DALdmdiMuHXS3vAr8h30-t7WKcp3I6tiWxxUtv2acjwijdm3OsYtKmSfjUm-T7xUL9kEUzVBjy0YgCeHyFea7MU_cMcT4Gw5zXbiP6AIBZUzTBuoUU/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image016" width="388" /></a> <br />
<ul><li><div align="left">To test that it is working create a new SP2010 document library and go to the library settings. Click on ‘Incoming e-mail settings’ </div></li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY6p9_5tmQ3ORT_cJ9k3EqoNcfx6gpra7i0n5fwNaks01tUvDJDFyNI9-BRDQvWT8rA6ybY2QOdo9X-ALmb3yCJJkEr1idGWpTDt7481mCRwWjzO7eez6LkIlBXkWjnQxpiFckFG4aLEM/s1600-h/clip_image0184.jpg"><img alt="clip_image018" border="0" height="186" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm_B-zhtInzjGvaX4lqk4wWadkZy3ajk8aq1If6S3AQHwUormQ0Tvsu4YwxN1W_8dZ47lehr_7DLwnVPTwZ3YdwgH9GKp7BW6a3T11BmoCkbO3jz9gBR24HpnauxjO8FccxYM19rbCGQk/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image018" width="394" /></a> <br />
<strong>5. Configure the Incoming e-mail settings for the library:</strong> <br />
<ul><li>Configure the Incoming e-mail settings for the library as illustrated in the screenshot below and click on ‘OK’ to save the settings. Note that I specify an e-mail address which of an account which I created in hMailServer earlier. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRmHuFzw_DJxrTeQl_608DhzYR_gVvj8qO8Zl0hN1TlX24B1b513regf5B6JDMCVMYxfm5QNwxGb0KW6WVKjGZ25XjDHsAVi8vMZTKZEu-7BW1h587k6vu-XypjZvVupaP6Oji6ERrS2I/s1600-h/clip_image0204.jpg"><img alt="clip_image020" border="0" height="272" src="http://lh4.ggpht.com/_SX0lCwhJEzc/TUrAx7qCjwI/AAAAAAAAAd0/dQUaZpGiDjU/clip_image020_thumb1.jpg?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image020" width="405" /></a> <br />
<strong>6. Test Everything:</strong><br />
<ul><li>Go back to Outlook and select the new POP3 mailbox. Create a new email to be sent from this account and send a test email to the email address of the document library and send the email. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPJB0VKMKAPpFUeyP2GB97VctB1DKYx3AVG0SLU1ldmzh8cB67rPczdYpEx7g-JFKSV8Nkn8125Ylgc8F5NZYvcyW3IzA2p-22UzvXxrjh2yy_Dh8bhsKM1wjSDahfcDEVR0XvFE_X2ds/s1600-h/clip_image0224.jpg"><img alt="clip_image022" border="0" height="98" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVQe5NXAWRT4-IRw7dam7-r6ijUlveiV85lKABRQ_cYuTzmKsbxq5KnCrHglwmHT62S1m1nnRvxrtSjI5sfqRUlcattyC5_lF9MG6uUE7cqrgf02ifgnnJ61jGLTu-xJhYnJPUSVg2z3k/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image022" width="419" /></a> <br />
<ul><li>After outlook performed a send-receive and the email is in your ‘sent items’ go to SharePoint and refresh the document library. </li>
<li>If everything went well you should see the new email in you library. </li>
</ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLnl5XYBTHRybfq3I_fcjk2CPbZ03Lz0WtXUUl8-W3u1XadP_UawwHwv4fP_1gGh6Vx1RwD4cxwJjFt2ViAn9YiHsp2SV9KV8-LSaqfn-xmDYOpbW4KNprxI-gg1mXiZNs-1tnVYTzUNk/s1600-h/clip_image0244.jpg"><img alt="clip_image024" border="0" height="151" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH4VAZ8Jgve7jJBQ_ns14N1zdgu5O3faeukiRF_d1qlgfOuiifePENFNT8hSJbd8Emso6_NPIu8S2VC4DMvyEK9FlqfBFEt2gM58nyfZhTn1hrBvwdhNTgX3TBjLLpqCEMQlzojiYTGE4/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image024" width="422" /></a> <br />
Note that when a library is configured to accept incoming email SharePoint will automatically add new columns to the library, but the new columns is not automatically added to the default view..so you can modify the view to see the additional information from the email: <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwwhcf8WLdOSHunLd12F6vpGgbH9s9OVyNEmGUPbXoeQSMDU63UZWzAUjuC9iafLy51ABav2v3KARO25vUPBCmMFulZz8UQBpU_iWvWPSE9mUyrg-qYJunyqnw9tbcHlhW-6JiAwuWLcg/s1600-h/clip_image0265.jpg"><img alt="clip_image026" border="0" height="313" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTKjjr69fvzeF0AjdRGUUrptSSX9XxkHLtFR6ESXvzN-oxGXns4CG06CjtYR73CWYfe25irXrrRv1_zd7oCUGwkHxYIr0VTAwJtpVb2GmWUboJibUFC84qcl3rmjcBwVLVyxvseGExjuo/?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="clip_image026" width="427" /></a> <br />
You will also notice that the body of the email is not available as a column. <br />
It is very easy to extract the body information by using an eml reader class. I will how you how to do this in a separate post. <br />
Keep in mind that your environment might be very different than mine and there can be a million things configured which might have an impact on getting this to work for you. My anti-virus was not a problem and my hMailServer service was automatically started. <br />
I hope this post will help you to get incoming e-mail configured for SharePoint 2010 on a Windows 7 machine. <br />
Have fun!!Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com9tag:blogger.com,1999:blog-429025622434259152.post-44187381963613169662011-01-28T11:14:00.002+02:002011-03-17T16:14:58.641+02:00SPFarm.Local is null (x86 vs. x64)This is one of those silly little mistakes which we very often overlook…and believe it or not, I have found many forums and blog posts where developers ask for help on this.<br />
I wanted to work with the SPFarm.Local object earlier this week and forgot that SharePoint 2010 targets the 64bit platform …duh… so when I tried the following code:<br />
<span style="font-family: times;">private void cmdCreateWebApp_Click(object sender, EventArgs e)<br />
{<br />
int myPort = 999; </span><br />
<blockquote><span style="font-family: times;"> SPFarm farm = SPFarm.Local;<br />
SPWebApplicationBuilder webAppBuilder = new SPWebApplicationBuilder </span><br />
<span style="font-family: times;"> (SPFarm.Local); </span></blockquote><span style="font-family: times;"> webAppBuilder.Port = myPort;<br />
SPWebApplication newApplication = webAppBuilder.Create();<br />
newApplication.Provision(); </span><br />
<span style="font-family: times;"> SPSite mySiteCollection = newApplication.Sites.Add("/", </span><br />
<span style="font-family: times;"> @"Mydomain\MyAdminUserName", "MyAdminUserEmail@CompanyName.co.za");<br />
mySiteCollection.Close();<br />
}</span><br />
I kept getting an exception and found that SPFarm.Local remains null.<br />
<a href="http://lh6.ggpht.com/_SX0lCwhJEzc/TUKJyal2KaI/AAAAAAAAAb4/AMOFTlL2gKI/s1600-h/image6%5B1%5D.png"><img alt="image" border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGWc1Z7yxnN96uayQvH-1p6e5ltBB8-NrxoSJiU60L1IYWwJU1tOrD_MAq5rCYK8sshLQGUaMAWknnvRDjFtLvbOnLKnMBQVE1Tr4uU70He2ZHrkMtWkouy_4EvJWp7Ir1_QvZPHV_FOI/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="484" /></a> <br />
The problem was that my VS2010 project was set to target a x86 platform and not the x64!!<br />
So, I opened my project properties and changed the platform target to x64.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-GriSd4vCUI29pjfYISGR1SNbXW76OguD_X5uSKlUQ0OjiDi84JLJhQmWF_RCyy-xz3bnvjxh9uHUDbjSJjCIF320PtRRzDgusmfKF35NuNx91jsqjjUckRk5DbHHuosUbPhJPNGMufU/s1600-h/image%5B2%5D.png"><img alt="image" border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhikKPMST7yKEo45_UYcaPmAOnp_tDGCEE5Dn_GkvYvlHR8R-b_9lDDeNvb5FclhBWD_3kUq2mshBDAwMinc-N0pfeAuuBW0U6VO8BLCqSsTZqRYkoy0rrNTZAvlNTL-R6m-wEev0ZW3xQ/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="470" /></a> <br />
Recompiled my code and ran it and it worked like a charm !<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq98nATmdljA9cvAk8mrVL8OiOH7XRdfMhizB9r36e4rUlR6rLTuwJZKz9JWB3gBjziZd12IdhD8U2gI4cMa6HUQbuZ1kHQfPk6_8fzdug09sYqCrZYh4xLCCRrCFUO1FYacMZzaifYJQ/s1600-h/image12%5B1%5D.png"><img alt="image" border="0" height="165" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG5h6LpJGdtGbVcZxRixanneXUNSaTUM5NpuGfAL6HcjhG6yARYCXlPWm0SGuB_pLFxQoPC4XUz4Cy7eXikhkrUOGhUFh2xxlPEu9IgvdWCcMkjtn5202m99Un_8E-ZxITkalJ-SOPisM/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="462" /></a><br />
Always remember guys…. <strong>X64</strong> !!!!!Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com0tag:blogger.com,1999:blog-429025622434259152.post-67175011799875756372010-12-23T15:34:00.002+02:002011-03-17T16:15:18.997+02:00WSPBuilder Error x86 vs. x64 (SP 2007)Today I came across 2 errors:<br />
<ol><li>Feature 'featureid' is not installed in this farm, and can not be added to this scope. </li>
<li>Cannot add the specified assembly to the global assembly cache: cablib.dll. </li>
</ol>I tried to deploy a WSP solution which we created a few weeks ago into a test SharePoint 2007 (MOSS) environment.<br />
I am using the CodePlex.SharePointInstaller (Setup.exe) and my solution.wsp file. <br />
This works well if I install it on my dev environment, but as soon as I try to install it on the test environment I get the following error at the very last step of the installation wizard.<br />
Error: Cannot add the specified assembly to the global assembly cache: cablib.dll.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHmq8dEUcHGvJacGRj4fxU3SYNbZRVQHimiNUI0VXVxHuISOrkR59sISwqJum1OohXzKQ4WYDhPgyJz23kS20qHHdlzZm7xOtSYdcXNMJUwZIxgmAYAW4drn7AY9_hyC068Cz1_C_gxvU/s1600-h/image%5B11%5D.png"><img alt="image" border="0" height="270" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzjY4562lE3I_h5a0GXJeLdqCifRGsE_Aa4T8yj1wN5a9Eqgb-fSzGtcxCpwlr9lnZTdoZW4RbiaOPaimFd7kGI46TDMYDXYVoPimG6jIRU9cqzWRELDNU6YRnBpVzwk3ItronnOuvP1c/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="344" /></a> <br />
I checked the 12 hive and my feature files are all there, but as soon as I try to activate a feature which contains an event receiver (assembly should be in GAC) I get the following error: <br />
Feature 'dc618366-db0a-4912-88d1-ad59e55bac90' is not installed in this farm, an <br />
d can not be added to this scope.<br />
After a bit of head-scratching I realized something. The solution was built on a 64bit dev environment and I am trying to install into a 32bit test environment.<br />
So this is what I had to do to get it to work:<br />
In Visual Studio, open you WSPBuilder project and go to project –> properties. Then change the Platform Target to x86.<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXXZQJ5CIRo5K-wvj3k_pgek49ea2Flxio8zZZFCjurE4oBaNJGro_LspDgIGfItRdJA2ZIlpep-5rZc72jNnfDLkxu-EMSvLgf0zbjoAG0YWJ5hn7072iFVb-NKvK0Xyu9LFcYIyLoxE/s1600-h/image%5B12%5D.png"><img alt="image" border="0" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq-zi2ZkJ8eSyH0cTkzKwF5EVf2AghaJHlgX1ECCx7snx8SsT_QR-wBVVSuGLMSFfy8jrfJNYMfxVjA5EHmUsIp9JU7TPkt3kO4WnAX7DaZYM3i2RHo8_LATBbbqw2hjnND-s3xgJ62XQ/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="344" /></a> <br />
Save your project and build it. <br />
Reinstall the WSP (run the SharePoint Solution Installer for your WSP to remove the old version and then run it again to install the new version.)<br />
This time the assemblies can be deployed to the GAC and you will now be able to activate your feature !!!<br />
Enjoy !Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com2tag:blogger.com,1999:blog-429025622434259152.post-26724029588398313702010-10-22T21:27:00.031+02:002010-10-22T21:41:20.579+02:00SP2010 Basics: Client Object Model<span style="font-family: "Trebuchet MS", sans-serif;">This post is part of the series which I will share in order to help you understand the new architecture of SharePoint 2010 and the impact thereof on you as developer.</span><br />
<br />
<span style="font-family: Trebuchet MS;">This week I had the opportunity to be a speaker at the AvePoint Interactive Theater at Teched Africa 2010. </span><br />
<br />
<span style="font-family: Trebuchet MS;">I decided to present an understanding of the SharePoint 2010 Managed Client Object Model. This is an introduction to how the Client Object model works, the benefits it brings and some very important considerations you have make.</span><br />
<br />
<span style="font-family: Trebuchet MS;">So...lets get cracking...</span><br />
<br />
<span style="color: blue; font-family: Trebuchet MS;"><strong>The Standard SharePoint 2007 Implementation</strong></span><br />
<span style="color: black; font-family: Trebuchet MS;">This diagram shows the standard communication between a SharePoint client browser and the server in a non customized environment.</span><br />
<span style="font-family: Trebuchet MS;">You can see that there is nothing special required on the client side. Simple comms to the server and then some execution there. </span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVdwAHziUHqhLbdpM_FnN6UXjhQX4jPNhU3suy6SV4UpwoVuVgkhU_YS-zlQycc3a3hsZExMRiba81Hm96PM0xmVakwwDqq0g3OXv8r4fNvc0tsi4TW6y2Jv1z2glilugr7WDL2M7akEs/s1600/1.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="252" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVdwAHziUHqhLbdpM_FnN6UXjhQX4jPNhU3suy6SV4UpwoVuVgkhU_YS-zlQycc3a3hsZExMRiba81Hm96PM0xmVakwwDqq0g3OXv8r4fNvc0tsi4TW6y2Jv1z2glilugr7WDL2M7akEs/s400/1.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: blue; font-family: Trebuchet MS;"><strong>What do we want to achieve?</strong></span><br />
<span style="color: black; font-family: Trebuchet MS;">Sometimes we want to extend SharePoint by adding functionality which will execute on the client-side. This means we want some mechanism to execute code on the client-side but then still interact with SharePoint data and functionality which reside on the server.</span><br />
<span style="font-family: Trebuchet MS;">Examples of this will be:</span><br />
<span style="font-family: Trebuchet MS;">1-Building Silverlight components, </span><br />
<span style="font-family: Trebuchet MS;">2-Build web parts which contains client side code like ajax or silverlight, </span><br />
<span style="font-family: Trebuchet MS;">3-Extend an existing Windows forms application which contains client-side code.</span><br />
<br />
<span style="color: blue; font-family: Trebuchet MS;"><strong>The Challenges in SharePoint 2007</strong></span><br />
<span style="color: black; font-family: Trebuchet MS;">The first challenge we faced in SharePoint 2007 was that if we wanted to extend an existing application which runs on the client side. In order to utilize SharePoint you had to use the native SharePoint Web Services or build new custom web services which will be hosted on the SharePoint server. Remember that custom web services will use the server object model. Deploying custom web services onto the server creates an administrative overhead and introduces a risk.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaLT3IkH_euvCC0wn5fryJksvn0lxcFt6TFuuPXZ1CGRSTmyULL_72ozr322VDKtd8O54U3Teb-1CEV2EWJA979IoF9_y7k28Bs6UF0ffFmK8H3phZKS7E4sPMHdJHhv5jbDMnQzoVX0c/s1600/2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="306" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaLT3IkH_euvCC0wn5fryJksvn0lxcFt6TFuuPXZ1CGRSTmyULL_72ozr322VDKtd8O54U3Teb-1CEV2EWJA979IoF9_y7k28Bs6UF0ffFmK8H3phZKS7E4sPMHdJHhv5jbDMnQzoVX0c/s320/2.png" width="320" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: Trebuchet MS;">The second challenge is in building silverlight applications which execute client-side.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnohTGMtTelWOvBszj56asv7nMgqI83T-y8MN965po_l9xGfKrBpizPvVXtCdTzXCnzhJtYn8KlgVaEyX4kWNL7IN88_Gdw6fGbaQHulmvcRQycwlPp0SKVh4ifx-YdPLUL4Z02U0VsT0/s1600/3.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="311" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnohTGMtTelWOvBszj56asv7nMgqI83T-y8MN965po_l9xGfKrBpizPvVXtCdTzXCnzhJtYn8KlgVaEyX4kWNL7IN88_Gdw6fGbaQHulmvcRQycwlPp0SKVh4ifx-YdPLUL4Z02U0VsT0/s400/3.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">So it is very obvious that we needed some mechanism to build client-side code which has an awareness and access to the SharePoint Server Object Model.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjhLtKrLDRYUzF9jDPQfWax2c9Kn-2kc-iO0BErlMUy88lL93T6yBDzPgRxGXx8aWCcgA1dF-PMIHHjWpePmahlTe4LqfCK4OcoCZp3EbWQrvcRbH43xQ8GejmYtoK7c3X50cOIwOep4Q/s1600/4.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="257" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjhLtKrLDRYUzF9jDPQfWax2c9Kn-2kc-iO0BErlMUy88lL93T6yBDzPgRxGXx8aWCcgA1dF-PMIHHjWpePmahlTe4LqfCK4OcoCZp3EbWQrvcRbH43xQ8GejmYtoK7c3X50cOIwOep4Q/s400/4.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">Microsoft helped solve this problem for us by introducing the SharePoint 2010 Client Side Object Model. Now we have a mechanism to extend SharePoint functionality through client-side code..without using SharePoint Web Services !!!</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWvCnl-UiS5-32B4y0-9A8JF9DVBm8shyphenhyphenaJihwb0lm0eNDc2I6dMFpKlw44l4IQLTfpWPNTT9vm-MLL-6nmmbbcSHh0MOWtOZ7S155TR7ap0uwWfHsdUIfnZr0hP_RwQxsGAvexr3pRUo/s1600/5.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="276" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWvCnl-UiS5-32B4y0-9A8JF9DVBm8shyphenhyphenaJihwb0lm0eNDc2I6dMFpKlw44l4IQLTfpWPNTT9vm-MLL-6nmmbbcSHh0MOWtOZ7S155TR7ap0uwWfHsdUIfnZr0hP_RwQxsGAvexr3pRUo/s400/5.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<strong><span style="color: blue; font-family: "Trebuchet MS", sans-serif;">How does the Client-Side Object Model work?</span></strong><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOwwGT96awxNUbLizaZgly_fQMUlZTx-vRR51lumdATm9LNQfuatWg-ec45nSkLClT9zcdtshUetqMwyugDb1XSGrh55NeIXXUHfUV_lyuJrPbJosRH_BuLVJlZ8_O9Lkf_FSuUpaajvA/s1600/6.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="375" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOwwGT96awxNUbLizaZgly_fQMUlZTx-vRR51lumdATm9LNQfuatWg-ec45nSkLClT9zcdtshUetqMwyugDb1XSGrh55NeIXXUHfUV_lyuJrPbJosRH_BuLVJlZ8_O9Lkf_FSuUpaajvA/s400/6.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: black; font-family: Trebuchet MS;">From the diagram you will see that we have the client on the left and the server on the right. The server contains the SharePoint Databases and the Server-side Object model.</span><br />
<span style="font-family: Trebuchet MS;">Between the server and client is a new WCF service called Client.svc</span><br />
<span style="font-family: Trebuchet MS;">When you reference the client-side object model in your code (example later in this post) , the internal proxy class takes care of sending requests and review responses via the WCF Service.</span><br />
<br />
<span style="font-family: Trebuchet MS;">The very important thing to notice here is that we dont want to send requests to the server and get a response for almost every line of code we execute. So how it is designed to work is that in your code you will construct the objects and execute standard SharePoint OM functions. The objects will be empty structures without properties and without data, and the functions will not execute right away.</span><br />
<span style="font-family: Trebuchet MS;">Then at logical points you bundle everything together and send it to the server for processing. The server will then unpack your bundled code and execute it in the correct order and return JSON to your client-side. Your objects will then be populated with data and properties and you can carry on executing more code. The important concept to understand is that you bundle empty objects together and send to the server when ready for processing.</span><br />
<br />
<span style="font-family: Trebuchet MS;">The SharePoint Foundation 2010 managed client model consist of <strong>Two Assemblies </strong>that <strong>contains five namespaces.</strong></span><br />
<br />
<strong><span style="font-family: Trebuchet MS;">There are 3 types of client object models.</span></strong><br />
<strong><span style="font-family: Trebuchet MS;">1-Managed Client Object model</span></strong><br />
<strong><span style="font-family: Trebuchet MS;">2-Silverlight Client Object model</span></strong><br />
<strong><span style="font-family: Trebuchet MS;">3-ECMAScript Client Object model</span></strong><br />
<br />
<strong><span style="color: blue; font-family: Trebuchet MS;">1-Managed Client Object model:</span></strong><br />
<span style="font-family: Trebuchet MS;">This is used to extend Windows Form applications, services, WPF applications, console applications etc.</span><br />
<span style="font-family: Trebuchet MS;">It consist of Microsoft.SharePoint.Client.dll (282 kb) and<br />
Microsoft.SharePoint.Client.Runtime.dll (146 kb)</span><br />
<br />
<strong><span style="color: blue; font-family: Trebuchet MS;">2-Silverlight Client Object model:</span></strong><br />
<span style="font-family: Trebuchet MS;"><span style="font-family: Trebuchet MS;">This is used to Silverlight Applications.</span><br />
<span style="font-family: Trebuchet MS;">It consist of Microsoft.SharePoint.Client.dll (282 kb) and<br />
Microsoft.SharePoint.Client.Runtime.dll (146 kb)</span><br />
<br />
<strong><span style="color: blue;">3-ECMAScript Client Object model:</span></strong><br />
JavaScript in our SharePoint user interface.<br />
It consist of:<br />
CUI.js (344 kb)<br />
SP.js (381 kb)<br />
SP.Core.js (13 kb)<br />
SP.Ribbon.js (208 kb)<br />
etc...<br />
<br />
You will notice that there are a few differences between the objects in the Client-Side Object model and the Server-side Object model:</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSPMyJmKFm7tEYgFnqNTBA1597ASELhEZ-W1bEa0pJwLP5pSDBQQ0jXeQroWE_P7IjPzP6BFe0GtEGKtAeLCD3velYk-lQrrfyprxzqFdVUaefEIDi0IXN57105Bugu4xwOj405-uX8fk/s1600/7.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="190" nx="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSPMyJmKFm7tEYgFnqNTBA1597ASELhEZ-W1bEa0pJwLP5pSDBQQ0jXeQroWE_P7IjPzP6BFe0GtEGKtAeLCD3velYk-lQrrfyprxzqFdVUaefEIDi0IXN57105Bugu4xwOj405-uX8fk/s320/7.png" width="320" /></a></div><strong></strong><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<strong><span style="color: blue; font-family: "Trebuchet MS", sans-serif;">Lets build some simple code:</span></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Create a new Visual Studio 2010 Console application</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Add a references to:</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Microsoft.SharePoint.Client.dll and </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Microsoft.SharePoint.Client.Runtime.dll</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">ensure your console app code look as follows:</span><br />
<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">using System; </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">using Microsoft.SharePoint.Client; </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">class DisplayWebTitle </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">{ </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">static void Main() </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">{ </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> ClientContext clientContext = </span><span style="color: blue; font-family: Times, "Times New Roman", serif;">new ClientContext("</span><a href="http://ltp-21:17819/"><span style="color: blue; font-family: Times, "Times New Roman", serif;">http://ltp-21:17819/</span></a><span style="color: blue; font-family: Times, "Times New Roman", serif;">"); </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> Web site = clientContext.Web; </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> clientContext.Load(site); </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> clientContext.ExecuteQuery(); </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> Console.WriteLine("Title: {0}", site.Title); </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">} </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">}</span><br />
<br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">Press control+F5 and see your code execute.</span><br />
<br />
<span style="color: blue; font-family: "Trebuchet MS", sans-serif;"><strong>Lets analyze the code:</strong></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">You inform the managed client OM about the operations that you want to take. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">This includes accessing the values of properties of objects (for example, objects of the List class, ListItem class, and Web class), CAML queries that you want to run, and objects such as ListItem objects that you want to insert, update or delete.<br />
Then you call the ExecuteQuery method.</span><br />
<span style="font-family: Trebuchet MS;">Only when you call the ExecuteQuery will the objects be bundled up and sent to the server for processing.</span><br />
<span style="font-family: Trebuchet MS;">No network traffice occurs before then.</span><br />
<br />
<strong><span style="color: blue; font-family: "Trebuchet MS", sans-serif;">Another Example:</span></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Create a new Visual Studio 2010 Console application</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Add a references to:</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Microsoft.SharePoint.Client.dll and </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Microsoft.SharePoint.Client.Runtime.dll</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">ensure your console app code look as follows:</span><br />
<br />
<span style="color: blue; font-family: Times;">using System; <br />
using Microsoft.SharePoint.Client; <br />
class Program <br />
{ <br />
static void Main() <br />
{ <br />
ClientContext clientContext = new ClientContext("<a href="http://ltp-21:17819/">http://ltp-21:17819/</a>"); <br />
List list = clientContext.Web.Lists.GetByTitle("Announcements"); <br />
CamlQuery camlQuery = new CamlQuery(); <br />
camlQuery.ViewXml = "<View/>"; <br />
ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(list);<br />
clientContext.Load(listItems); <br />
clientContext.ExecuteQuery(); <br />
foreach (ListItem listItem in listItems) <br />
Console.WriteLine("Id: {0} Title: {1}", listItem.Id, listItem["Title"]); <br />
} <br />
}<br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;"></span></span><br />
<span style="color: blue; font-family: Times;"><span style="color: black; font-family: "Trebuchet MS", sans-serif;">Press control+F5 and see your code execute.</span></span><br />
<br />
<span style="font-family: Trebuchet MS;">Again, the code will be bundled up and only be sent to the server for processing when the .ExecuteQuery() run.</span><br />
<span style="font-family: Trebuchet MS;">This means that although you called the list.GetItems the CAML did not execute at that time.</span><br />
<span style="font-family: Trebuchet MS;">When you call the .ExecuteQuery(), the server will receive your code, unpack it and execute it in the correct sequence and return the objects populated with data and properties.... all processed on the server side... and ready to be further used on the client-side !!!! </span><br />
<br />
<span style="font-family: Trebuchet MS;">Amazing, isnt it ! Well I hope this gives you a nice overview of the Client Side Object model in SharePoint 2010.</span><br />
<br />
<span style="font-family: Trebuchet MS;">Have Fun !</span>Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com9tag:blogger.com,1999:blog-429025622434259152.post-32996921893393278982010-08-23T21:30:00.003+02:002010-08-26T19:54:49.025+02:00SharePoint 2007 Site Templates vs. Site Definitions<span style="font-family: "Trebuchet MS", sans-serif;"></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">There is an ongoing debate between SharePoint developers regarding the best approach for packaging and deploying customized SharePoint solutions.</span><br />
<span style="font-family: Trebuchet MS;">One easy approach is to use site templates, but my opinion is that for a developer who are concerned about system performance and who needs finer control over cusomization, a site definition is the better option.</span><br />
<br />
<span style="font-family: Trebuchet MS;">I found that building some sort of <strong>custom site provisioning provider</strong> works the best. </span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">Below is my analysis of the differences between site definitions vs. site templates and at the bottom is a summary of the approach I prefer for deploying custom SharePoint solutions. </span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><strong><u>What is a Site Definition?</u></strong></span><br />
<span style="font-family: Trebuchet MS;">A Site definition is the core definition of what a site is in SharePoint.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">User content on a SharePoint site is located in a SQL Server database. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">All the code and the pages that are used to administer and render the SharePoint site are stored as physical files on the web server. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">A site definition exists as physical files on the web server and defines, through the use of SharePoint’s XML schema (known as CAML), the lists, columns, features etc. that should be created / activated when a site is created. (The files includes .aspx pages and .xml files)</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">A site definition is installed on file system of web front ends, located at ..\12\Template\SiteTemplates. This directory is language-neutral.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Site definition files are cached in memory on the server at process start-up of Microsoft Internet Information Services (IIS), which improves scalability and performance by reducing unnecessary data storage or retrieval, and by allowing uncustomized pages to be reused across sites. The information contained in these files is pulled from the cache at run time. Pages and list schemas are read from the site definition files but appear to be actual files within a site.</span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><strong><u>What is a Site Template?</u></strong></span> <br />
<span style="font-family: "Trebuchet MS", sans-serif;">A site template (*.stp file) is created through the user interface or through implementation of the object model. It is a package containing a set of differences and changes from a base site definition. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">The site template package is stored as a CAB-based file that can be downloaded or uploaded to site collections by users with the appropriate rights. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">It is not as performant as a pure site definition as site definitions are cached on start of IIS on the web front ends while site templates are stored and hence need to be fetched from the content database and merged with the site definition code at runtime to render the site.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><strong><u>Deciding Between Site Definitions and Custom Site Templates</u></strong></span> <br />
<strong><u></u></strong> <br />
<strong><u><span style="font-family: "Trebuchet MS", sans-serif;">Site Templates</span></u></strong> <br />
<ul><li><span style="font-family: "Trebuchet MS", sans-serif;">Easy to create.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">You do not need to be a server administrator on the Web server to create and deploy site templates.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Easiest way for system administrators to extend SharePoint without requirement for development skills.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Deployment is simple because template data is stored centrally in the configuration database.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Because it is slow to store templates in and retrieve them from the database, site templates can result in slower performance.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">The contents of unghosted pages are routed through the Safe Mode parser, which prevents server-side code from executing, and which depends entirely on the Safe Controls list specified in the web.config file of the wwwroot directory to determine which controls can be rendered at run time.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">You can modify a site template without affecting existing sites created by the template.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Custom templates can be modified without affecting existing sites that have been created from the templates.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Custom templates are not created in a development environment.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">If the site definition on which the custom template is based does not exist on the front-end server or servers, the custom template will not work.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">If you plan to transfer a site template to separate farm, that the farms have the same versions installed of SharePoint installed. (hotfixes,etc.) This is due to the dependence site templates have on the original base site definition they were created from.</span></li>
</ul><strong><u><span style="font-family: "Trebuchet MS", sans-serif;">Site Definitions:</span></u></strong><br />
<ul><li><span style="font-family: "Trebuchet MS", sans-serif;">Complex and laborious to create.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Administrators must always be involved in the deployment of site definitions.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Most appropriate for third-party developers.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Deploying a site definition requires more work.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Site definition files are cached in memory on the server at process start-up of Microsoft Internet Information Services (IIS), which improves scalability and performance by reducing unnecessary data storage or retrieval.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Uncustomized pages to be reused across sites.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">You can achieve a finer level of customization by directly editing all the schema files.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Custom site definitions are version and upgrade independent.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Subsequent upgrades to SharePoint Products and Technologies may overwrite existing default site definitions. Using custom site definitions excludes your sites from potential upgrade issues.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">There is no easy way to modify site definitions once they are deployed</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Doing anything other than adding code can break existing sites</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Users cannot apply a SharePoint theme through a site definition.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Customizing site definitions requires access to the file system of the front-end Web server.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Multiple root-level pages -- In a site definition, you can define several root-level pages. Instead of your sites having one page, they can have many. </span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Template picker pages -- You have the ability to change the icon that displays in conjunction with the template so it stands out as you create the templates.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Microsoft doesn't support changes made to a site definition after you've created the sites. </span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Multiple lists of the same type -- Because of the structure of CAML and the ONET.XML file, you can't create multiple lists from the same list definition and put them on the same page.</span></li>
</ul><strong><u><span style="font-family: "Trebuchet MS", sans-serif;">Summary of my preferred approach:</span></u></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">I found that building a <strong>custom site provisioning provider </strong>works the best. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">This means that I build my SharePoint artefacts - lists, libraries, web parts, custom forms, etc. using SharePoint, SharePoint Designer and Visual Studio. When I am then ready to package and deploy my custom SharePoint solution I use the SharePoint Solutions Generator - part of Microsoft SharePoint Developer Tools 9.0 to create list and library definition features.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Once I have my list and library definitions in place I create a Visual Studio WSP Builder project with an Feature Event Receiver. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">In the "activate" event I add logic to activate the definition features and in the "deactivating" event I do a cleanup (deactivate definition features and remove web parts)</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<strong><u><span style="font-family: "Trebuchet MS", sans-serif;">This means the following will happen when one of my solutions are deployed / retracted:</span></u></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">1. The user creates a blank SharePoint site. (previously team site)</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">2. The user runs a Setup.exe file.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">3. This file is the un-customized Codeplex Solutions Installer and will read configuration data from Setup.exe.config</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">4. The file will open a deployment wizard which guides the user through a series of screens to ensure successful solution deployment.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">5. After successful deployment the user follow instructions from the deployment guide to execute a single stsadm.exe command.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">6. This command will activate a single hidden feature.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">7. The single feature which gets activated will do the following on the site:</span><br />
<ul><li><span style="font-family: "Trebuchet MS", sans-serif;">Set the new site title.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Check environment for previously installed features which are still active</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Activate Web Features in the correct order </span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Activate Site Collection Features</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows activation of generic site collection features – shared among more than 1 solution.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Clear Site Structure – remove unwanted artefacts</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Set Site Structure – build Quick Launch Items, Set Web Parts on Default.aspx page etc.</span></li>
</ul><span style="font-family: "Trebuchet MS", sans-serif;">8. During deactivation of the single “configuration” feature the following will happen:</span><br />
<ul><li><span style="font-family: "Trebuchet MS", sans-serif;">Set the new site title back to default.</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Deactivate Web Features in the correct order </span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Deactivate Site Collection Features</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Clear Site Structure – remove unwanted artefacts</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">I do not delete lists or libraries which contain data – do not want to delete data.</span></li>
</ul><strong><u><span style="font-family: "Trebuchet MS", sans-serif;">Benefits of this approach:</span></u></strong><br />
<ul><li><span style="font-family: "Trebuchet MS", sans-serif;">Allows dependencies between hidden features - lookup lists</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows list to be automatically instantiated with default data</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows library content – like UDCX files to be configured with new environmental values (link InfoPath Form to dynamic data connections)</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows activation of web part features to site collection scope</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows validation and upload of InfoPath Forms (using site collection feature)</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Allows publishing <span id="goog_914088969"></span><span id="goog_914088967"></span>of InfoPath Form to site collection forms library</span></li>
<li><span style="font-family: "Trebuchet MS", sans-serif;">Leverage off the benefits of using definitions. </span></li>
</ul><br />
<span style="font-family: Trebuchet MS;">I hope this will help you to choose the best approach for the kind of SharePoint solutions which you need to deploy... good luck !!</span><br />
<br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><strong><u>Further reading and references:</u></strong> </span><br />
<a href="http://itfootprint.wordpress.com/2007/04/18/sharepoint-site-template-vs-site-definition/"><span style="font-family: "Trebuchet MS", sans-serif;">http://itfootprint.wordpress.com/2007/04/18/sharepoint-site-template-vs-site-definition/</span></a><br />
<a href="http://msdn.microsoft.com/en-us/library/ms980852.aspx"><span style="font-family: "Trebuchet MS", sans-serif;">http://msdn.microsoft.com/en-us/library/ms980852.aspx</span></a><br />
<a href="http://mymemorysucks.wordpress.com/2009/02/25/site-definitions-vs-site-templates-and-site-provisioning-providers/"><span style="font-family: "Trebuchet MS", sans-serif;">http://mymemorysucks.wordpress.com/2009/02/25/site-definitions-vs-site-templates-and-site-provisioning-providers/</span></a><br />
<a href="http://my.advisor.com/doc/17614"><span style="font-family: "Trebuchet MS", sans-serif;">http://my.advisor.com/doc/17614</span></a><br />
<a href="http://blogs.msdn.com/b/brianwilson/archive/2008/07/13/site-definitions-versus-site-templates-and-deciding-on-the-correct-customization-approach.aspx"><span style="font-family: "Trebuchet MS", sans-serif;">http://blogs.msdn.com/b/brianwilson/archive/2008/07/13/site-definitions-versus-site-templates-and-deciding-on-the-correct-customization-approach.aspx</span></a>Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com5tag:blogger.com,1999:blog-429025622434259152.post-58196309395215541202010-08-16T22:17:00.018+02:002011-02-10T10:33:00.807+02:00SharePoint 2010 Provider Consumer Web Parts<span style="font-family: "Trebuchet MS", sans-serif;">In this tutorial I will show how to develop Provider and Consumer web parts and connect them through an Interface.</span><br />
<span style="font-family: Trebuchet MS;">The result will be the ability to have two web parts on a SharePoint 2010 page and filter the contents of the consumer web part on the data from the provider web part. This is almost like a master - detail view.</span><br />
<span style="font-family: Trebuchet MS;">You can view the same functionality by looking at the standard SharePoint web parts. Modify a web part --> select Connections and the "Provide data to..." or "Receive data from..."</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEAh2MJ6sCidM1H0Tq4x6barREf81trDCJmEXPPjbjcKrbLUvpSyW9Fwc-qW-XSV_k4KtnL8cRr9GyNXq3kvpSuw-rzWGshV5B81iVyJuBEcOxSrfsG1UVfjGxyRukUSJxRU0Th4U3TyU/s1600/3.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="172" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEAh2MJ6sCidM1H0Tq4x6barREf81trDCJmEXPPjbjcKrbLUvpSyW9Fwc-qW-XSV_k4KtnL8cRr9GyNXq3kvpSuw-rzWGshV5B81iVyJuBEcOxSrfsG1UVfjGxyRukUSJxRU0Th4U3TyU/s640/3.png" width="640" /></a></div><span style="font-family: "Trebuchet MS", sans-serif;"></span><span style="font-family: "Trebuchet MS", sans-serif;">and then...</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVjoeVMDqQi4t-R0G69Ye6_l1rlUZHtzAH6pBFUbDqxcZIIwrt3oe1cG6tCW3gU87MVD1DxTC77sb5FeH2YkdsNS3O0YwosGAZI0l5aMcZ7BOduRFEfqTZAAFUlanu7ZoLk0WOtQYGWvk/s1600/4.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="201" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVjoeVMDqQi4t-R0G69Ye6_l1rlUZHtzAH6pBFUbDqxcZIIwrt3oe1cG6tCW3gU87MVD1DxTC77sb5FeH2YkdsNS3O0YwosGAZI0l5aMcZ7BOduRFEfqTZAAFUlanu7ZoLk0WOtQYGWvk/s400/4.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: blue; font-family: "Trebuchet MS", sans-serif;"><strong><u>Lets Get Started:</u></strong></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">I will show the detailed steps to:</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">1 - Develop a Connection Interface</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">2 - Develop a simple provider web part.</span><br />
<span style="font-family: Trebuchet MS;">3 - Develop a simple consumer web part.</span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><strong><u>1 - Develop a Connection Interface.</u></strong></span><br />
<strong><u></u></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Open Visual Studio 2010 and create a new project. In the New Project dialog window, select Visual C# --> SharePoint 2010 --> Empty SharePoint Project.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Provide a descriptive name and click on OK.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Select to deploy the solution as a "Deploy as Farm Solution" and click on Finish.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Wait for the solution to be created in Visual Studio.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Now we will create the web part connection interface which is responsible for exchanging connection information between a provider and consumer web part.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">In the Solution Explorer, right-click on your project and select "Add --> New item".</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">In the Add New Item dialog window, select Visual C# --> Code --> Interface.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Enter <strong>ITask </strong>in the Name textbox and click the Add button.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Open ITask.cs in code view and change the visibility of the interface to Public and add the following code inside the interface:</span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">namespace WebPartConnectors</span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">{</span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"> <span style="color: red;"><strong>public</strong></span> interface ITask</span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"> {</span><br />
<span style="color: red; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"> <strong>int Id { get; }</strong></span><br />
<span style="color: red; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"><strong> string Name { get; }</strong></span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;"> }</span><br />
<span style="color: blue; font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;">}</span><br />
<br />
<strong><u>2 - Develop a simple provider web part:</u></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">In the Solution Explorer, right click on your project and select Add --> New Item…</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Select Visual C# --> SharePoint 2010 Web Part.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Enter ProviderWebPart in the Name textbox and click Add.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Open ProviderWebPart.cs in code view and in the ProviderWebPart class declaration, implement ITask.</span><br />
<span style="color: blue;"><span style="font-family: "Trebuchet MS", sans-serif;">public class ProviderWebPart : Microsoft.SharePoint.WebPartPages.WebPart, <span style="color: red;"><strong>ITask</strong></span></span></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Insert the following code after the ProviderWebPart class declaration. </span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">This code block implements the ITask web part connection interface and adds a local variable to the web part.</span><br />
<span style="color: red;">DropDownList _objPicker = null;</span><br />
<span style="color: red;">int ITask.Id </span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> get </span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> return int.Parse(_objPicker.SelectedValue); </span><br />
<span style="color: red;"> } </span><br />
<span style="color: red;"> } </span><br />
<span style="color: red;">string ITask.Name </span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> get </span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> return _objPicker .SelectedItem.ToString(); </span><br />
<span style="color: red;"> }</span><br />
<span style="color: red;"> }</span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">Update the CreateChildControls method to contain the following code:</span><br />
<span style="color: blue;"></span><br />
<span style="color: blue;">protected override void CreateChildControls()</span><br />
<span style="color: blue;">{</span><br />
<span style="color: red;"> try</span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> _objPicker= new DropDownList(); </span><br />
<span style="color: red;"> using (SPSite spSite = new SPSite(SPContext.Current.Web.Url)) </span><br />
<span style="color: red;"> using (SPWeb spWeb = spSite.OpenWeb()) </span><br />
<span style="color: red;"> {</span><br />
<span style="color: red;"> SPList objList = spWeb.Lists["Tasks"];</span><br />
<span style="color: red;"></span><br />
<span style="color: red;"> foreach (SPListItem objListItem in objList.Items)</span><br />
<span style="color: red;"> {</span><br />
<span style="color: red;"> _objPicker.Items.Add(new ListItem(objListItem.Title, objListItem.ID.ToString())); </span><br />
<span style="color: red;"> }</span><span style="color: red;"> </span><br />
<span style="color: red;"> } </span><br />
<span style="color: red;"> _objPicker.AutoPostBack = true;</span><br />
<span style="color: red;"> this.Controls.Add(_objPicker);</span><br />
<span style="color: red;"> }</span><br />
<span style="color: red;"> catch (Exception ex)</span><br />
<span style="color: red;"> { </span><br />
<span style="color: red;"> this.Controls.Clear(); </span><br />
<span style="color: red;"> this.Controls.Add(new LiteralControl(ex.Message));</span><br />
<span style="color: red;"> }</span><br />
<span style="color: blue;">}</span><br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">Insert the following ConnectionProvider property below the CreateChildControls method. This provides the Connection Provider interface point for the ProviderWebPart:</span> <span style="color: red;">[ConnectionProvider("Task Name and ID")] </span><br />
<span style="color: red;">public ITask NameDoesNotMatter() </span><br />
<span style="color: red;">{ </span><br />
<span style="color: red;"> return this;</span><br />
<span style="color: red;">}</span><br />
<br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;">Save your solution and build. Ensure that there are no build errors before you proceed.</span><br />
<br />
<br />
<strong><u><span style="font-family: "Trebuchet MS", sans-serif;">3 - Develop a simple consumer web part.</span></u></strong><br />
<span style="font-family: "Trebuchet MS", sans-serif;">In the Solution Explorer, right click on your project and select Add --> New Item…</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Select Visual C# --> SharePoint 2010 Web Part.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Enter ConsumerWebPart in the Name textbox and click Add.</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><br />
</span><br />
<span style="font-family: "Trebuchet MS", sans-serif;">Insert the following code inside the ConsumerWebPart class declaration:</span> <br />
<span style="color: red;">ITask _provider = null; </span><br />
<span style="color: red;">Label _lbl = null;</span><br />
<span style="color: red;"><br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">Update the CreateChildControls method to contain the following code:</span><br />
<span style="color: red;">protected override void CreateChildControls()</span><br />
<span style="color: red;">{</span><br />
<span style="color: red;">try </span><br />
<span style="color: red;">{</span><br />
<span style="color: red;">_lbl = new Label();</span><br />
<span style="color: red;">if (_provider != null)</span><br />
<span style="color: red;">{</span><br />
<span style="color: red;">if (_provider.Id > 0) </span><br />
<span style="color: red;">{ </span><br />
<span style="color: red;">_lbl.Text = _provider.Name + " was selected."; </span><br />
<span style="color: red;">} </span><br />
<span style="color: red;">else</span><br />
<span style="color: red;">{ </span><br />
<span style="color: red;">_lbl.Text = "Nothing was selected."; </span><br />
<span style="color: red;">} </span><br />
<span style="color: red;">} </span><br />
<span style="color: red;">else </span><br />
<span style="color: red;">{ </span><br />
<span style="color: red;">_lbl.Text = "No Provider Web Part Connected."; </span><br />
<span style="color: red;">}</span><br />
<span style="color: red;">this.Controls.Add(_lbl);</span><br />
<span style="color: red;">}</span><br />
<span style="color: red;">catch (Exception ex)</span><br />
<span style="color: red;">{ </span><br />
<span style="color: red;">this.Controls.Clear(); </span><br />
<span style="color: red;">this.Controls.Add(new LiteralControl(ex.Message)); </span><br />
<span style="color: red;">}</span><br />
<span style="color: red;">}</span> <br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><span style="color: red;"><span style="color: black;"><span style="color: red;"><span style="color: black;">Insert the following ConnectionConsumer property below the CreateChildControls method. This provides the Connection Consumer interface point for the ConsumerWebPart:</span></span></span></span></span><span style="color: red;"><span style="color: black;"><span style="color: red;">[ConnectionConsumer("Name and ID")]</span></span></span><br />
<span style="color: red;">public void ThisNameDoesNotMatter(ITask providerInterface)</span><br />
<span style="color: red;">{</span><br />
<span style="color: red;"> _provider = providerInterface;</span><br />
<span style="color: red;">}</span><br />
<span style="color: black;"></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><span style="color: black;">Save the solution, Build the solution and Deploy the solution.</span><br />
<span style="color: black;"></span><span style="color: black;">Go to your target SharePoint 2010 site and refresh the site.</span><br />
<span style="color: black;">Edit a page and add the two new web parts.(ensure that you have some data in the SharePoint Tasks list)</span></span><br />
</span><span style="color: red;"></span> <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRYKWSD1qSUd9M3LM5PhLkm0i9Eo5XBwzlnHAz2f8yrWpAbLcjfEKXX4o4T-zG2RA23R1TUNWQ3gSg4te3xJZnaS4fy28Bkycrl3zvpw6T0adLmUuStQvpTpaCkmLba5BaEA7l_tQoGsE/s1600/0.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="217" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRYKWSD1qSUd9M3LM5PhLkm0i9Eo5XBwzlnHAz2f8yrWpAbLcjfEKXX4o4T-zG2RA23R1TUNWQ3gSg4te3xJZnaS4fy28Bkycrl3zvpw6T0adLmUuStQvpTpaCkmLba5BaEA7l_tQoGsE/s400/0.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">View your two new web parts on the page:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNFmM9v06PkWLjzkfz5rU6oQIOdLRI167jiszRg-TS3uOvzF6ci3NrjS0Ny5Z7MZ-DjbCnAEXbRVpjNIOOP_lL-BkjAgeFQ-xtSo6DqhAhsNu8zpnOJQACDqCBfeowZQEkTXxjE_Onr94/s1600/1.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="366" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNFmM9v06PkWLjzkfz5rU6oQIOdLRI167jiszRg-TS3uOvzF6ci3NrjS0Ny5Z7MZ-DjbCnAEXbRVpjNIOOP_lL-BkjAgeFQ-xtSo6DqhAhsNu8zpnOJQACDqCBfeowZQEkTXxjE_Onr94/s400/1.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: black;"></span><br />
<span style="font-family: "Trebuchet MS", sans-serif;"><span style="color: black;">Edit the page again and select the ProviderWebPart and click on Edit Web Part.</span><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFl3QO8jramq0D6ilebyOvMelOvlfRq16CKjwvwzKDFMSPxhPgibWwj7wCaUWRtPTmIVLeJlTH25tt0c-_xw9aNAlVufoU6DBZyuAZq1_rs16nwFbLlMQDa0FXOh7XXLOOBIsYIcNCqU4/s1600/2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="233" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFl3QO8jramq0D6ilebyOvMelOvlfRq16CKjwvwzKDFMSPxhPgibWwj7wCaUWRtPTmIVLeJlTH25tt0c-_xw9aNAlVufoU6DBZyuAZq1_rs16nwFbLlMQDa0FXOh7XXLOOBIsYIcNCqU4/s400/2.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">Select the ProviderWebPart again, but this time select "Connections" --> "Send Task Name and ID To" --> ConsumerWebPart.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEAh2MJ6sCidM1H0Tq4x6barREf81trDCJmEXPPjbjcKrbLUvpSyW9Fwc-qW-XSV_k4KtnL8cRr9GyNXq3kvpSuw-rzWGshV5B81iVyJuBEcOxSrfsG1UVfjGxyRukUSJxRU0Th4U3TyU/s1600/3.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="171" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgEAh2MJ6sCidM1H0Tq4x6barREf81trDCJmEXPPjbjcKrbLUvpSyW9Fwc-qW-XSV_k4KtnL8cRr9GyNXq3kvpSuw-rzWGshV5B81iVyJuBEcOxSrfsG1UVfjGxyRukUSJxRU0Th4U3TyU/s640/3.png" width="640" /></a></div><br />
<br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">Now, if you select an item from the dropdown list control in the providerwebpart you will see the corresponding data change in the consumerwebpart.</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVjoeVMDqQi4t-R0G69Ye6_l1rlUZHtzAH6pBFUbDqxcZIIwrt3oe1cG6tCW3gU87MVD1DxTC77sb5FeH2YkdsNS3O0YwosGAZI0l5aMcZ7BOduRFEfqTZAAFUlanu7ZoLk0WOtQYGWvk/s1600/4.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="201" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVjoeVMDqQi4t-R0G69Ye6_l1rlUZHtzAH6pBFUbDqxcZIIwrt3oe1cG6tCW3gU87MVD1DxTC77sb5FeH2YkdsNS3O0YwosGAZI0l5aMcZ7BOduRFEfqTZAAFUlanu7ZoLk0WOtQYGWvk/s400/4.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<span style="font-family: "Trebuchet MS", sans-serif;"><span style="color: black;">This way you will be able to build master-detail views or web part filters based on selections of other web parts.</span><br />
<br />
<span style="color: black;">Enjoy !!</span></span>Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com14tag:blogger.com,1999:blog-429025622434259152.post-13074141497788593562010-08-16T13:03:00.000+02:002010-08-16T13:03:54.348+02:00Basic SharePoint 2010 LINQ Web Part<span style="font-family: "Trebuchet MS", sans-serif;">In this tutorial I will show how to develop a very basic visual web part which uses LINQ (LINQ to SharePoint) to populate data from a SharePoint 2010 list into a SPDataGrid control.</span><br />
<br />
<span style="font-family: Trebuchet MS;">The web part will look like this:</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGiVvRboXbCxXwhghxyvOdwuZQxKMnOCqs0We2MWXVQU3zFbMQ9mbCHVFcVALa45lrjydZtGz24mI5XdCTBvsYx2Ht83jwVmF9Mkdlb0pZ79heKsT2qIO4V5Mp0e1j8a_oEw2X7Qcyr6k/s1600/00.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="190" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGiVvRboXbCxXwhghxyvOdwuZQxKMnOCqs0We2MWXVQU3zFbMQ9mbCHVFcVALa45lrjydZtGz24mI5XdCTBvsYx2Ht83jwVmF9Mkdlb0pZ79heKsT2qIO4V5Mp0e1j8a_oEw2X7Qcyr6k/s640/00.png" width="640" /></a></div><strong><u><span style="color: blue; font-family: "Trebuchet MS", sans-serif;">Overview:</span></u></strong><br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;">The following steps will be taken to develop the web part which contains LINQ.</span><br />
<span style="font-family: Trebuchet MS;">1- Create a Visual Web Part.</span><br />
<span style="font-family: Trebuchet MS;">2- Create a LINQ proxy class.</span><br />
<span style="font-family: Trebuchet MS;">3- Use a LINQ provider to read data from a SharePoint list.</span><br />
<span style="font-family: Trebuchet MS;">4- Show the data in a SPDataGrid control.</span><br />
<br />
<strong><u><span style="color: blue; font-family: "Trebuchet MS", sans-serif;">Lets get started</span></u></strong><br />
<span style="color: black; font-family: "Trebuchet MS", sans-serif;"><strong><u><span style="color: blue;">1- Create a Visual Web Part:</span></u></strong></span><br />
<br />
Create a new Visual Studio 2010 project. From the installed templates select Visual C# --> SharePoint --> 2010 --> Visual Web Part.<br />
Provide a suitable name and click on OK.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdsENTKI0CaR5FO1CjUrD2WGulr_D-MN1jTzcE2dHM8iEqDUPEu_417kaGdRjOqF4VWXnRoTEoD-gLqhzC56NPa4nWusvHLd_8SWhypFh_nGXRDEyloqsZLWmM-n6QxBB8aMTURN3T1Bk/s1600/0.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="257" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdsENTKI0CaR5FO1CjUrD2WGulr_D-MN1jTzcE2dHM8iEqDUPEu_417kaGdRjOqF4VWXnRoTEoD-gLqhzC56NPa4nWusvHLd_8SWhypFh_nGXRDEyloqsZLWmM-n6QxBB8aMTURN3T1Bk/s400/0.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Select to deploy the solution as a Farm Solution and click on "Finish"<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv9QDRlyW1Ps33mFEQ3R2GIGvWr7-fL32Yg9scVM_QEL4RVco4F47O5Hqjp41X4jygrXi6fQh0FW_Q8xStYXb02fL-OrqV48A-0RF7MfPB9ufbD6l9FyIcHdLm0EW0nIv2aQB-p-Mg6Gk/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjv9QDRlyW1Ps33mFEQ3R2GIGvWr7-fL32Yg9scVM_QEL4RVco4F47O5Hqjp41X4jygrXi6fQh0FW_Q8xStYXb02fL-OrqV48A-0RF7MfPB9ufbD6l9FyIcHdLm0EW0nIv2aQB-p-Mg6Gk/s400/1.png" width="400" /></a><br />
<br />
Once the project is created, open the VisualWebPart1.webpart (from the solution explorer)<br />
Change the Title and Description values and save the file.<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"><properties></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"><property name="<span style="color: red;"><strong>Title</strong></span>" type="string"><span style="color: red;">MyFirstSPLinqWebPart</span></property></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"><property name="<span style="color: red;"><strong>Description</strong></span>" type="string"><span style="color: red;">My First SQL LINQ Web Part</span></property></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></properties></span> <br />
<br />
<strong><u><span style="color: blue;">2- Create a LINQ proxy class.</span></u></strong><br />
In the Solution Explorer, right-click on your project and select Open Folder in Windows Explorer.<br />
<br />
Hold Shift key and right click anywhere in the Explorer Window and select Open Command Window Here to open the command prompt window in the current project directory.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRwNTpUkCWTPyuM8us5RKYnTt8f4AiAJPiGm7pdxA5MTmIjSBNHyh2a3neTf_farG-BrK2Kr709xbZMg9jkPnZmxCMmmo6gnJekW5RrI_NUt1iOpJnyTs2OSX3-wncRkWi-_jMNlRLQIY/s1600/2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="232" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRwNTpUkCWTPyuM8us5RKYnTt8f4AiAJPiGm7pdxA5MTmIjSBNHyh2a3neTf_farG-BrK2Kr709xbZMg9jkPnZmxCMmmo6gnJekW5RrI_NUt1iOpJnyTs2OSX3-wncRkWi-_jMNlRLQIY/s400/2.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Type the following command in the command prompt and press Enter to set the path to the SharePoint 2010 folder:<br />
<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">set path=%path%;c:\program files\common files\microsoft shared\web server extensions\14\bin</span><br />
<br />
Type the following command in the command prompt and press Enter to generate the Linq-to-SharePoint proxy code. <br />
the yoursharepointsiteaddress value should reflect the URL of your SharePoint 2010 site.<br />
(mine was <a href="http://svr-x:12345/">http://svr-x:12345/</a>)<br />
For yourwebpartnamespace value I used MyFirstSPLinqWebPart.VisualWebPart1.<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">spmetal.exe /web:http://<span style="color: red;"><strong>yoursharepointsiteaddress</strong></span> /namespace:<span style="color: red;"><strong>yourwebpartnamespace</strong></span> /code:SPLinq.cs</span><br />
so my command looked like:<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">spmetal.exe /web:http://svr-x:1234 /namespace:MyFirstSPLinqWebPart.VisualWebPart1 /code:SPLinq.cs</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></span><br />
<br />
Note – you may get warnings about content types for list Form Templates. You can safely ignore this warning and continue.<br />
Close the command window and switch back to Visual Studio.<br />
In Visual Studio, in the solutions explorer, right click on your project and select Add Existing Item --> Navigate to the <span style="color: blue;">SPLinq.cs</span> file (should be in your project folder)..select the file from the Add Existing Item dialog window and click Add.<br />
<br />
Next we will add a reference to Linq to our project. <br />
In the Solution Explorer right click on References and click on "Add Reference". <br />
Select Microsoft.SharePoint.Linq from the list of .net references and click on OK. <br />
(the file is available on the server as <span style="color: blue; font-family: Times, "Times New Roman", serif;">C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.SharePoint.Linq.dll</span>) <br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09Y12Fxl0y5OZWQ1E0TdqC8-AX5lcECGEbBxU8EAX8H47cn_0z1Xt87VWOrN9ql-23Hu6WcyzT4SnRpsZfOXUg-H_-jNsQiOPNegfO6Ei8FkjP2yzaIYa6A8PAncdeBiOAxPB7Pzrgnw/s1600/3.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="260" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi09Y12Fxl0y5OZWQ1E0TdqC8-AX5lcECGEbBxU8EAX8H47cn_0z1Xt87VWOrN9ql-23Hu6WcyzT4SnRpsZfOXUg-H_-jNsQiOPNegfO6Ei8FkjP2yzaIYa6A8PAncdeBiOAxPB7Pzrgnw/s400/3.png" width="400" /></a></div> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<strong><u><span style="color: blue;"></span></u></strong> <br />
<strong><u><span style="color: blue;"></span></u></strong> <br />
<strong><u><span style="color: blue;">3- Use a LINQ provider to read data from a SharePoint list & populate the GridView:</span></u></strong> <br />
<br />
In Solution Explorer, expand VisualWebPart1 and double-click on VisualWebPart1UserControl.ascx.<br />
<br />
Add the following code to the bottom of the file <strong><span style="color: red;">below the code which already exists in the file.</span></strong>. <br />
This is to generate the user control to construct the grid view.<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"><%@ Import Namespace="Microsoft.SharePoint.WebControls" %> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"><SharePoint:SPGridView id="spGridView" runat="server" AutoGenerateColumns="false"></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> <HeaderStyle HorizontalAlign="Left" ForeColor="Navy" Font-Bold="true" /> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> <Columns></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> <SharePoint:SPBoundField DataField="Title" HeaderText="Title"></SharePoint:SPBoundField> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> <SharePoint:SPBoundField DataField="Body" HeaderText="Body"></SharePoint:SPBoundField> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> <SharePoint:SPBoundField DataField="AssignedTo" </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> HeaderText="AssignedTo"></SharePoint:SPBoundField> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> </Columns> </span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></SharePoint:SPGridView></span><br />
<br />
In the Solution Explorer, right click on VisualWebPart1UserControl.ascx and select View Code. Add the following using statements to the code behind: <br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">using Microsoft.SharePoint.Linq;</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">using Microsoft.SharePoint;</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">using System.Linq;</span><br />
Insert the following code inside the Page_Load method:<br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">SPLinqDataContext dc = new SPLinqDataContext(SPContext.Current.Web.Url);</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"></span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">EntityList<Task> Tasks = dc.GetList<Task>("Tasks");</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">var empQuery = from taskitem in Tasks</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> select new</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> {</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> taskitem.Title,</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> Body = taskitem.Body,</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> taskitem.AssignedTo,</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;"> };</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">spGridView.DataSource = empQuery;</span><br />
<span style="color: blue; font-family: Times, "Times New Roman", serif;">spGridView.DataBind();</span> <br />
<br />
Build the project and deploy.<br />
Refresh your SharePoint site.<br />
Edit an existing page and add your new web part to the page (select your new web part)<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc47OQSb2e46qY_GA7ztN_fN8EAvpFSEL7aGiqV14MuvKpv7DQ31oNrnzFBYa0ErUUDGHEwzI-OXKMplPv8cdYFi_iLqh4SUHiQv7Unpgb-RGlNU201esbL-JhsjTtm8xImjJ-AU1m1L4/s1600/4.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="252" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc47OQSb2e46qY_GA7ztN_fN8EAvpFSEL7aGiqV14MuvKpv7DQ31oNrnzFBYa0ErUUDGHEwzI-OXKMplPv8cdYFi_iLqh4SUHiQv7Unpgb-RGlNU201esbL-JhsjTtm8xImjJ-AU1m1L4/s400/4.png" width="400" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
You will now see the data which is loaded from a SharePoint list using LINQ and represented in a SPDataGrid.<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFLIkA65tSihu-iINn0XnWTN2vm5zWfBBXWnx7GmZXxfKE9sel9QJNjHSCwo3dnItsVuqoJI4ZetbXTWK3PXfsEuBqwbCYryW4oVclEpaK5SKCbBikriBgk_fp9JNXwDnWTLIMEs-Ytpc/s1600/5.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="201" ox="true" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFLIkA65tSihu-iINn0XnWTN2vm5zWfBBXWnx7GmZXxfKE9sel9QJNjHSCwo3dnItsVuqoJI4ZetbXTWK3PXfsEuBqwbCYryW4oVclEpaK5SKCbBikriBgk_fp9JNXwDnWTLIMEs-Ytpc/s400/5.png" width="400" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Enjoy !!Johan Olivierhttp://www.blogger.com/profile/12362783186069410694noreply@blogger.com4