Posts

Showing posts from October, 2011

Sharepoint 2010 - Migrate List-based Workflows between Sites and Site Collections

Thank you Gavinmckay, you saved me! From his blog:  http://gavinmckay.wordpress.com/2011/08/29/howto-move-or-migrate-sharepoint-2010-list-based-workflows-between-sites-and-site-collections/ I’ve experienced this issue a lot when trying to migrate workflows between test SharePoint 2010 farms and production farms, in particular with workflows attached to lists. When moving a workflow to another site collection or server farm, the association to the list is broken and the workflow cannot be attached to the list. You also cannot use SharePoint designer to fix this via the standard methods as the unattached workflow cannot be reattached to the list. List-based workflows are tied to three different lists – the “main” source list where the data is held (such as a Forms library or custom list), a task list, and a workflow history list. The latter in particular is tricky, because it is a hidden list and cannot be viewed via the normal interface. The fix for this is to modify the source

Sharepoint 2010 - Enable/Disable Ribbon Button with EcmaScript

I show you a detailed example of how to enable and disable a ribbon button according to the current user’s group. The example uses “EnabledScript” attribute of the CommandUIHandler of the ribbon button. Then the EnabledScript is built with EcmaScript to find groups and user info. Lets Start with creating a Ribbon button first. 1. Create a empty project. 2. Deploy it as a Farm solution. 3. Right click on the feature and click “Add feature”. 4. Right click on the project and add a new “Empty Element” item. 5. Next add the below code to add a custom Ribbon button to your document library. <Elements xmlns=”http://schemas.microsoft.com/sharepoint/” > <CustomAction Id=”ButtonForGroupUsersOnly” Location=”CommandUI.Ribbon” RegistrationId=”101″ RegistrationType=”List” Title=”Owners Group Button”> <CommandUIExtension> <CommandUIDefinitions> <CommandUIDefinition Location=”Ribbon.Library.ViewFormat.Controls._children”> <Button Id=”Ribbon.L

Blogger - Redirect when you change Blog URL

Recently I changed URL of my blog from giorgioguerrieri.blogspot.com to webdevshareetc.blogspot.com. I know that my posts linked in facebook, google+, twitter have the old URL, so I search for a solution, a way to redirect post giorgioguerrieri.blogspot.com/2010/eccccc to webdevshareetc.blogspot.com/2010/eccccc, without 404 or other annoying message of Page Not Found. So, I googled but nothing. I found my solution with this process. NOTE: it works if you have a personal site and it's used not for personal site. I use my site for development, so when you navigate to www.giorgioguerrieri.it your browser redirect to my blog. You have change URL of your blog (giorgioguerrieri to webdevshareetc.blogspot.com) Create a new blog with URL equals to old URL (new blog giorgioguerrieri.blogspot.com) Go to Settings in new Blog and set Redirect to your public domain (I've www.giorgioguerrieri.it). Important! You have to insert URL as "www.yourdomain.com?", yes, with &

Sharepoint 2010 - Modify Documents Properties with ECMA Script

Finally I found the way to modify document properties with ECMA Script! It's not an hard work for Document Libraries with no mandatory check out. Here the script: function updateDocument(action, docLibId, docId, fieldName, fieldValue) {     var context = new SP.ClientContext.get_current();       var web = context.get_web();       var docLibGuid = new SP.Guid(docLibId);       var docLib = web.get_lists().getById(docLibGuid);       var doc = docLib.getItemById(docId);       doc.set_item(fieldName, fieldValue);         doc.update();       context.executeQueryAsync(Function.createDelegate(this, this.successUpdateDocument), Function.createDelegate(this, this.failed));  } function successUpdateDocument(sender, args) {       //reload page if success       location.reload(true); } But when we set check out mandatory, we have message that we cannot modify document not checked out. So, I have to check out document in this script. I change script as shown below: fun

SharePoint 2010 WebPart Properties not saving

Image
I lost many time to find the way to save properties of a custom web part in Sharepoint 2010. All my classes, methods, properties are defined correctly, but when I deploy web part and I try to save props, values were not saved and web part load with his default values. Then I search for solution and I found that it is due to disposing the current web (SPContext.Current.Web). I understood that I don't have to dispose SPContext.Current.Web object in my code and neither use using(SPWeb web = SPContext.Current.Web). The solution is to use directly SPWeb web = (new SPSite(SPContext.Current.Site.ID)).openweb(SPContext.Current.Web.ID); to initiate a new web object and then dispose it after using. The Save button finally saved properties values!