Tuesday, October 8, 2013
Deploy files on Azure Blob Storage, for a SharePoint Online project, in a repeatable process
Monday, August 12, 2013
How to retrieve the SPGroup Description
In this days I worked on a timer job that sync the groups from a site collection to another.
For the first time on my life, copy the description of the group to another was a software requirement.
My expectation was copy the description from the property Description of the SPGroup class:
and set the description of the new group by the same property after that I created it. But if you use it the description that is not show on the group page:
to do that we should work with the property SiteUserInfoList of SPWeb class:
var g = syncWeb.SPWeb.SiteGroups [ "Group Name" ];
var text = ( SPFieldMultiLineText )syncWeb.SPWeb.SiteUserInfoList.Fields [ SPBuiltInFieldId.Notes ];
SPListItem groupItem = syncWeb.SPWeb.SiteUserInfoList.GetItemById ( g.ID );
map.Description = text.GetFieldValueAsText ( groupItem [ text.InternalName ] );
into map.Description we will have the html for the About me column, but we can use it when we need have to create a new group as:
SPWeb.SiteGroups.Add ( group.Name, adm, adm,
string.Format ( "{0} {1}", group.Description, Constants.GROUP_SYNC_DESC ) );
enjoy
Monday, July 22, 2013
My London SUGUK event’s slides and code examples (18 July 2013)
at this link: http://www.slideshare.net/Salvodif/java-script-for-the-c-developer
you can find the slides from my SUGUK session. For the code examples please take a look here: https://github.com/Salvodif/suguk18july
enjoy,
.S
Wednesday, July 17, 2013
SPWeb and the adventure with the property bag
Chronologically speaking the last funny thing was about the SPWeb Property Bag.
First of all in SPWeb object we can find:
and
According to MSDN the Properties property:
This property returns only a subset of the metadata for a website. To get all the metadata, use the AllProperties property.
Basically this property is still there for backward compatibility, so now it’s better to use the AllProperties property.
That’s ok but let me talk about an issue that I got. If you are working with the property bag and you want to remove a key/value from it an easy and normal way seem to be:
if ( web.AllProperties.ContainsKey ( property.Key.ToString ( ) ) )
{
web.AllProperties.Remove ( property.Key.ToString ( ) );
}
web.Update ( );
but that way doesn’t work and neither does setting the value to null before calling the Remove method (as many suggest around the web).
The only useful way that I've found is to do this:
if ( web.AllProperties.ContainsKey ( property.Key.ToString ( ) ) )
{
web.DeleteProperty ( property.Key.ToString ( ) );
}
From MSDN: This method deletes a property from the AllProperties property that is a key/value pair.
Taking a look inside the Microsoft.Sharepoint.dll about the DeleteProperty method seems it calls the Remove method of the HashTable as I wrote above:
and that is what is inside that method:
Maybe a little bit more scouting would make the idea clearer.
enjoy
.S
Wednesday, July 10, 2013
Print Properties of an Object
Let think about this, you wanna print all the properties in a SPWeb property bag. To do that you can write a script like this:
$site = Get-SPSite -Identity https://mySPSite $site.RootWeb.AllProperties | % {$_ | Format-Table | Out-String)}
If you want can show the Properties Table as a List just changing the Format-Table command with Format-List
see ya!