Posts

Showing posts from 2012

SharePoint 2010 - Recursive Query in List/Library

CAML query is by default non recursive. If you execute a CAML query, you will end up with items from the list root folder. You have to define extra query options as shown below in case you want to query all folders and sub folders within a list (Recursive Query) : query.ViewAttributes = "Scope='Recursive'"; From: http://blogs.technet.com/b/meacoex/archive/2010/10/24/recursive-and-folder-scoped-linq-queries-in-sharepoint-2010.aspx

Sharepoint 2010 - The Text property is read-only and cannot be set

In a site, logged in with Admin, edit with Sharepoint Designer. Copy default master page to create a new one. Chech out new master page and edit some rows. Then, save and set as Default Master Page for site. Open browser, navigate to site and all it's ok! Fine! Now, I log with another user and.... ERROR ! "The Text property is read-only and cannot be set" In Sharepoint Log, you find somethings like below: System.Web.HttpException: The 'Text' property is read-only and cannot be set.    at System.Web.UI.ControlBuilder.AddProperty(String filter, String name, String value, Boolean mainDirectiveMode)     at System.Web.UI.ControlBuilder.PreprocessAttributes(ParsedAttributeCollection attribs)     at System.Web.UI.ControlBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs) .... Resolution! Go to Sharepoint Designer and check in your new master page!! Then, retry with other user...

Sharepoint 2010 - About Uselessness of Content Query Web Part?

Image
.. Why Content Query Web Part...?? I did not found any reason to use Content Query Web Part.. Or maybe, I am no really skilled to find a way to use it with a real reduction of configuring costs. In the same time I build custom XLS for CCQWP, I can develop a Custom web part with Visual Studio... No, I think I develop custom wp in less time... Sure, with minor performance, but it works anywhere and it has simple governance, for me... And you? You found way to use "simple" CQPW? Maybe, only a demoralization time..

Sharepoint 2007 - Modal Dialog Sharepoint2010-Like

Image
Or .. How to show modal dialog with page content only. In Sharepoint 2007 we don't have a client script framework that shows modal dialogs with ligthbox effect, as in Sharepoint 2010. We can reproduce with a lot of jquery ui and similia. In MOSS, we can use the function javascript of core.js,  commonShowModalDialog. Open Site and in Homepage, add a Content Editor Web Part with this simple code: <a href="javascript:openInModalDialog()">CLICK HERE</a> <script type="text/javascript"> function openInModalDialog() {   var url = "/Lists/Calendar/Calendar.aspx";   commonShowModalDialog(url,"resizable: no; status:no; scroll: no; help: no; center: yes; dialogwidth:800px; dialogHeight:500px;",RetrieveItemValue); } </script> Click on link opens modal dialog, but we show the entire page in window: Now, open Calendar page in edit mode. Add Content Editor Web Part at the bottom of the page with code belo...

Sharepoint 2010 - Customizing Quick Launch with pages

Image
How to show different quick launch menu items in different pages? The quick launch in Sharepoint is an object common to all pages of the site. To show menu items according to the page you visited, I followed client side method with javascript (jquery). Here's how, using Sharepoint Designer 2010. On css stylesheet of the site, I added this instruction, which hides all the items in the Quick Launch: . s4-ql ul.root> li { display: none; } Then, make note of the position of the menu items in the quick lanuch: eg. 0 - Document Libraries 1 - Lists 2 - MyLink      0 - MySubLink1      1 - MySubLink2 3 - MyOtherLink 4 - MyLastLink The pages follows the following rules: Page1 shows 0,1,4 Page2 shows 0,2,3 Page3 shows 0,2 (and sub ​​links 1), 3.4 And now, I change the master.page, adding references to jquery and inserting the following code: //get all items in the quick launch var li_nav = $(".vertical-menu>ul>li"); //get...

Resizing Cross-Domain IFrame with Javascript

I tried to find a way to pass height of page loaded in an IFRAME to parent document in order to reset the height of the IFRAME with javascript. It's a simple coding, but .. if you use IFRAME with a page in a different domain, you cannot access to properties of page opened in IFRAME and from page to opener. The idea is to be able to pass the value of the height of the content at regular intervals, using a javascript function, and try to read it by the parent. This applies to the height value, but works for any data, of small size, to be passed client side from content of the iframe to container in a cross domain situation. Obviously, if we can access page open iframe in edit. NOTE: Both domains must be added to Trusted Sites. Let's see how. I put the following function in the page that I want to load iframe: setInterval (function () {this.frames.status = getHeight();}, 400); getHeight function () {      var height;     [we calculate body heig...

Sharepoint 2010 - Client Validation of a Custom Form with Javascript

What to do if you want to perform a client validation with Javascript, in your custom new/edit form. The submit button cames with this code in onclick event: if ( !PreSaveItem()_ ) return false;WebForm_DoPostBackWithOptions(new .. . The PreSaveItem function invokes PreSaveAction function that you can override with your own definition. If PreSaveAction returns true, then form proceeds to save data, otherwise, it stops with alert. With Sharepoint Designer 2010, open form with Edit in Advanced Mode and insert code below: <!-- call jquery --> <script type="text/javascript" src="/SiteAssets/js/jquery.min.js"></script> <!-- override PreSaveAction --> <script type="text/javascript"> function PreSaveAction() {     var field_to_validate = $("select[title='TITLE OF FIELD']").val();    if(field_to_validate == "") {      alert("Warning: complete field_to_validate!");      return ...

Sharepoint 2010 - Create a Site Collection Template without Errors...

(I know, the title of this post is misleading ...) I had to create a template for Site Collection and, according to various posts and tutorials, the procedure seems very simple: Save site as template, Import into a new project in Visual Studio 2010, changing some scope, put into hidden some features and recompile. Then, upload wsp on farm, deploy and so on ... Everything is fine until I try to create a new Site Collection using the new template. The page loading... and ... error "File not found"!! In the log file, nothing about which files it is searchin for. I found no solution, my template was not so complex, but did not understand why this error. In the end, the lighting has arrived. We know that is not possible (in theory) save a site as a template if it has the Publishing Feature activated. "In theory", because through the direct link to the page, you can save it as template. But Microsoft does not support this type of template (site with publis...

Get QueryString Value with JQuery

I found this solution to get value of querystring with jquery. Add jquery script to your page and insert this code in script to define the new function: (function($) {     $.QueryString = (function(a) {         if (a == "") return {};         var b = {};         for (var i = 0; i < a.length; ++i)         {             var p=a[i].split('=');             if (p.length != 2) continue;             b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));         }         return b;     })(window.location.search.substr(1).split('&')) })(jQuery); Then, call it for your querystring parameter: var q = $.QueryString["query"]; Fine!

Sharepoint 2010 - Full Crawl fails on Web Application with Access Denied Error

I started a Full Crawl of Content DataSource and I get this error message: " Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has "Full Read" permissions on the SharePoint Web Application being crawled " even if I use an account with Full Read permission on that Web Application. I go on Search Server machine for Sharepoint farm, with credential used for Default Content Access Account , and I try to navigate to site collection in that Web Application:  I get error "Access Denied", browser asks me for credential and then "Error 401".. So, the problem was that account used for Default Content Access cannot browse to site collections in Web Application, from the server search. I correct with this post, from Microsoft: " You receive error...

Sharepoint 2010 - Show/Hide columns with Conditional Formatting

Image
In a previous post I describe how show/hide columns of a list with UI language, using javascript . Now, I show how do the same using Conditional Formatting feature of Sharepoint Designer 2010. I have same list with columns for language, DescriptionIT, DescriptionEN. Open Sharepoint Designer 2010, and edit page with list view. Select List and add Parameter for language taken from Cookies: Then, select tag <TH> for List Column DescriptionIT, using selector at the bottom of page: Now, in the Condition Formatting panel, click on Create and Apply Formatting: In the filter clause, click on Advanced and write code as below: Then, click OK, and Set Style, in Layout section, set Display:none: Click OK and OK again. Repeat steps selecting <TD> tag for values of column DescriptionIT. Do it again for DescriptionEN column, with condition "($cookieLanguage!='1033')". Save page and view in browser, checking colum...

Sharepoint 2010 - Change UI Language with javascript

If you want to use html/javascript to change UI language, you can use the script below: (Note: in the page, there is the function OnSelectionChange, so you have to change name if you want to use other feature in) function OnSelectionChange(value) {     var today = new Date();     var oneYear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);     var url = window.location.href;     document.cookie = "lcid=" + value + ";path=/;expires=" + oneYear.toGMTString();     window.location.href = url; } And in page, set the flags for change language: <a href="javascript:OnSelectionChange(1040)">     <img width="32" height="20" src="/SiteAssets/flag_ita.png" border="0" alt="Italiano"/> </a> <a href="javascript:OnSelectionChange(1033)">     <img width="32" height="20" src="/SiteAssets/flag_eng.png" border="0" alt=...

Sharepoint 2010 - Filter Web Part with Current User Language

Image
I have to filter a List/Library on current User Language. I add column Language Code, with values of platform language codes (1033 for english, 1040 for italian). With Sharepoint Designer 2010, I modified Web Part and I set a new parameter as below, using COOKIE source parameter with "lcid" name: and the filter : So, web part shows me documents/items filtered with language = italian/english choosen by user! For italian: For english:

Sharepoint 2010 - Multilanguage Site - Show column in current language

Image
In multilanguage site feature, Sharepoint 2010 does not translate content of web part and metadata. We have to find a way to show to user content or metadata in current language. I used a list with columns with content in language and a lot of jquery to show and hide columns for current language. I have a list with "DescriptionIT" and "DescriptionEN" columns. Then, I set a view with both columns visible. In this view, I added a content query web part whit code below. In this code, I search for current language, i.e. "Italian", then search for column with "DescriptionIT", and hide all columns but "DescriptionIT" (with name starting with "Decsription"). Result is that if I change language (with Select Display Language), I see only column in respective language. Simple and cross platform. Here the code: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type=...

Sharepoint 2010: BeforeProperties and AfterProperties in Event Receivers!

Event Receiver is a great feature for Sharepoint 2010, but I spent many time to discover how Properties works.. Especially BeforeProperties and AfterProperties.. I found a great post with resume all available values. Here table and below the link! http://www.synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=122 These are the values of the properties in  List  events: List BeforeProperties AfterProperties properties.ListItem ItemAdding No Value New Value Null ItemAdded No Value New Value New Value ItemUpdating No Value Changed Value Original Value ItemUpdated No Value Changed Value Changed Value ItemDeleting No Value No Value Original Value ItemDeleted No Value No Value Null And here are the properties available in  Library  events: Library BeforeProperties AfterProperties properties.ListItem ItemAdding No Value No Value Null ItemAdded No Value No Value New Value ItemUpdating Original Value Changed Value Original Value ItemUpdated Ori...

Sharepoint 2010: Deactivate and Activate Feature with Power Shell

Sometimes, you can have trouble with feature upgrade in your site. Especially if you upgrade event receiver, adding new trigger. If you have many sub site using this feature, you can use Power Shell to deactivate and activate feature. This mine: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $rootUrl = "http://[SERVERNAME]" $site = Get-SPSite $rootUrl foreach($web in $site.AllWebs) {   $url = $web.Url   if($url -ne $rootUrl){    foreach($feature in Get-SPFeature -Web $url)    {     $featureName = $feature.DisplayName     if($featureName -eq "FEATURE NAME")     {       "Disable and Enable feature $featureName in $web"       Disable-SPFeature -Identity FEATURENAME -Url $url -Confirm:$false       Enable-SPFeature -Identity  FEATURENAME -Url $url       break;     }    }   } }

Sharepoint 2010 Globally Reusable Workflows does not update WF instance in Subsite if re-published: PS Script save me

I defined a Globally Reusable WF for a custom Content Type in root site, with a custom form with InfoPath. I defined a sub site with a list using the global WF template created for its Content Type. Everything works without problems. Now I need to change the WF (both in form and in the process). BUT.. If I edit only the form with InfoPath and then I publish the form, I see correctly the new form in WF on subsites. If I change the WF logic too (any actions) and publish WF (in root site), changes are not perceived by WF on subsites. WF on subsite is updated only if, on subsite, I open WF to change (from browser) and save it. I expect that you can update all WF in subsite using template in root site, without having to reopen and resave each WF in each subsite. I don't understand if it's a bad configuration or a issue on Globally Reusable WF. (I opened question in Technet Forum, here ) UPDATE: Sometimes, I update a WF (form and logic) and logic has been correctly pub...

Will SharePoint 15 (2013) finally get an App Store?

Image
by Mark Jones | Jan 31, 2012 Just decided to have a few minutes investigation into the recently released  SharePoint 15 Technical Preview Managed Object Model SDK  to see if there is any insight into what's coming up! Before I get started, please note this information is all deduced from the Object Model documented in the SDK and is solely my opinion of what "may" happen. The SDK clearly states that it is "subject to change", so don't bet the crown jewels on anything in this post! The SPApp Store classes (SPApp, SPAppCatalog, SPAppInstance, SPApplicationCredentials, etc.) Well, it looks like SharePoint's going to get some tight integration with an App Store (aka market place). This has been on the cards for quite a while, but I thought they'd have to get the API developed to support it eventually. Reading between the lines, I think there's going to be somewhere in the SharePoint GUI to browse for an "App" in an on-line App S...

Sharepoint 2010 - Assign Category to your Site Template (without VS)

Image
Set your Site Template in a Category is (maybe) simple with Visual Studio, but not the faster way. I tried with success by editing some xml in WSP package. Here step by step my solution. Save your site as template, "My_Site". Go in Solutions Gallery and download your My_Site.wsp package on desktop. Rename extension from .wsp to .cab. Use your tool to extract and create CAB archive, I used SimplyZip . Extract My_Site.cab and open to edit file Elements.xml in folder “ My_SiteWebTemplate ”. Add attribute DisplayCategory="My Site Templates" in tag “< WebTemplate> ” and save file. Use your tool to create new file My_Site.cab with all files from original cab and modified file. Note : with SimplyZip use Drag&Drop to set files and folders to add in cab. Change extension from .cab to .wsp and upload My_Site.wsp on Solutions Gallery. Now, try to create new Site: in the " Filter By:" section, you see  My Site Templates category...

Sharepoint 2010 - Advanced Settings for Document library in SharePoint 2010 using PowerShell

Image
In this article we will be seeing how to change the Advanced Settings for Document library in SharePoint 2010 using PowerShell and c#. Go to Document Library => Library Settings => General Settings =>Advanced Settings. Using C#: using  (SPSite site = new SPSite("http://serverName:1111/"))             {                 using (SPWeb web = site.RootWeb)                 {                     SPList docLibrary=web.Lists["Doc Library"];                      // Change the advanced settings          ...