Pages

Tuesday, October 8, 2013

Deploy files on Azure Blob Storage, for a SharePoint Online project, in a repeatable process

Note 1 - thanks to Gist you need to see the post's page to have a look at the code
When we work in a project we try to create an automatic deploy process closest to the 100% of the process itself; but we also know that is not possible to cover the entire 100% because we have some manual steps, these usually are around 15% and 30% of all the automatic process. So lets call this process: semi-automatic deploy process.
That perception can grow if we are working on SharePoint Online and we need to deploy some assets on Azure, because new issues are put in the middle of the process.....
just remember to change this subscription with the new blog's address

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:

10-08-2013 10-29-57

10-08-2013 11-18-18

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:

10-08-2013 11-22-27

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)

Hi guys,
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

Sometimes working with SharePoint it feels like you had 10 Jägerbombs in a row last night.
Chronologically speaking the last funny thing was about the SPWeb Property Bag.
First of all in SPWeb object we can find:
properties 

and
allproperties 

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:
reflector_delete_property 
and that is what is inside that method:


 inside the delete method


Maybe a little bit more scouting would make the idea clearer.
enjoy
.S

Wednesday, July 10, 2013

Print Properties of an Object

This is a note for me just in case to forget how to print all the properties of an object in powershell.
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!