Jacqueline van der Holst

Link.ToMyThoughts()

Session ins and outs of Duet Enterprise Feature Pack 1 on TechDays Netherlands

For the TechDays in the Netherlands I posted a wildcard session, and people can vote to see the session. The session will be about the ins and outs of Duet Enterprise Feature Pack 1. I will address the following topics and more:

1. What will you get when you use Duet Enterprise for communication between SAP and SharePoint?

2. How does this work?

3. What do you need to be able to use it? What do you need to configure?

4. What are benefits and what are challenges?

5. Authentication

6. How can these projects best be done?

7. Oppertunities and lessons learned

8. Development in SharePoint and the BCS

So if you are interested and coming to the techdays, please vote for my session http://www.techdays.nl/WildcardSessieDetail.aspx?sid=62352

 

20/12/2011 Posted by | Duet Enterprise | Leave a Comment

Creating a hiërarchy of document library folders and subfolders using SharePoint 2010 Client Object Model

Working with the client object model of SharePoint 2010 I wanted to create a way to be able to create a multiple subfolder structure within a document library. Here I describe the way you can do that. At first a procedure was written to create a subfolder under a folder in the documentlibrary:

public void CreateSubFolderForFolder(string subfolderName, string folderName)

{

//This procedure creates a subfolder for a folder in a documentlibrary list

var clientContext = new ClientContext(Uri);

var list = clientContext.Web.Lists.GetById(ListId);

if (list != null)

{

ListItemCreationInformation newFolder = new ListItemCreationInformation();

newFolder.UnderlyingObjectType = FileSystemObjectType.Folder;

//This function gets the complete url to the folder where the subfolder is created for

newFolder.FolderUrl = GetUrl(folderName);

newFolder.LeafName = subfolderName;

ListItem item = list.AddItem(newFolder);

item.Update();

clientContext.ExecuteQuery();

}

}

In order to create a complete layer of subfolders in a  documentlibrary the function above should be placed in a loop. But how can you  pass a hiërarchical structure to such a function. You can do that for instance by supplying the following structure: /Folder1/Subfolder2/Subfolder3. This states that Subfolder2 needs to be created underneath Folder1 and Subfolder3 needs to be created under Subfolder2. When you pass the structure to the function below this is done:

public void CreateFolderSubFolderStructure(string relativeFolderPath)

{

string totalFolderName = String.Empty;

string[] folders = relativeFolderPath.Split(‘/’);

foreach (string folderName in folders)

{

if (!String.IsNullOrEmpty(folderName))

{

//This checks if the folder already exists

Folder folder = GetFolder(folderName);

if (folder == null )

{

if (!String.IsNullOrEmpty(totalFolderName))

{

CreateSubFolderForFolder(folderName, totalFolderName);

}

else

{

//This function creates a folder directly under the root

CreateFolder(folderName);

}

}

totalFolderName += “/” + folderName;

}

}

}

The GetFolder function in the function above checks wether the folder already exists. If it exists than the folder is not created again but

used to create the next folder.  See below:

 

private Folder GetFolder(string folderName)

{

var clientContext = new ClientContext(Uri);

var list = clientContext.Web.Lists.GetById(ListId);

Folder existingFolder = null;

if (list != null)

{

FolderCollection folders = list.RootFolder.Folders;

string folderUrl = GetUrl(folderName);

IEnumerable<Folder>existingFolders= clientContext.LoadQuery(

folders.Include(

folder => folder.ServerRelativeUrl)

);

clientContext.ExecuteQuery();

existingFolder = existingFolders.FirstOrDefault(

folder => folder.ServerRelativeUrl.ToLower() == folderUrl.ToLower());

}

return existingFolder;

}

 

05/09/2011 Posted by | Client Object Model, SharePoint 2010, Uncategorized | Leave a Comment