Create Folders under document library: Nintex Workflow

I spent almost a day to figure this one out. Lot of people they might say folders are not good for SharePoint. In some cases they are right but not all the time. Lets take this business scenario when you dealing with SharePoint 2013 that to with Metadata navigation settings + Skydrive Pro sync process???

I know its kind of makes sense to go with folders at that point of time right……? Yes. Found a nice post by John Scott

Here I’m going through couple of ways to do it to make it happen.

1. SharePoint designer workflows

2. Nintex 365 workflows

For now I’m skipping “SharePoint designer workflows”, lets concentrate on “Nintex 365 workflows”.

Nintex 365 workflow to create folders in a document library:

There are 2 ways to accomplish our task. 1 cool thing about both the approaches is, first it will check for the folder with the specified name exists or not. If not it will try to create the folder. If folder already exists, it won’t delete or try to create, simple ignores the process.

1. In NIntex workflows, we have an option called as – CREATE ITEM. So configure that accordingly if you are trying to create a top level folder.

Create Folder Nintex 2

2. In Nintex workflows, we have an option called as – CALL WEB SERVICE. So configure that accordingly if you are trying to create a folder/sub folder. In the screenshot below, RootFoler attribute in ‘Batch’ is very important.

Create Folder Nintex 1

For example: If your library is XYZ and trying to create ‘Folder1’, below are the params to web service

  • destinationLib – XYZ
  • rootFolder – /XYZ
  • tempPath – Folder1

same way if you are trying to create a subfolder called ‘Folder1Level1’ under ‘Folder1’, below are the params to web service

  • destinationLib – XYZ
  • rootFolder – /XYZ/Folder1
  • tempPath – Folder1Level1

Hope it helps some of you folks……Happy WORKflowing……..

The SPPersistedObject, XXXXXXXXXXX, could not be updated because the current user is not a Farm Administrator

“The SPPersistedObject, Microsoft.SharePoint.Administration.SPJobDefinition, could not be updated because the current user is not a Farm Administrator”.

Since we were running the SPJobDefinition.Update() and related code under SPSecurity.RunWithElevatedPrivileges() I was under the impression that the code already ran as Farm Admin.
After some more tracing through the code I found a property in SharePoint API which controls this behavior:
Microsoft.SharePoint.Administration.SPWebService.ContentService.RemoteAdministratorAccessDenied
After setting this property from PowerShell the issue went away with no code changes.

function Set-RemoteAdministratorAccessDenied-False()
{
# load sharepoint api libs
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null
# get content web service
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security
$contentService.RemoteAdministratorAccessDenied = $false
# update the web service
$contentService.Update()
}
Set-RemoteAdministratorAccessDenied-False

Below steps to be followed to make it work.

  • Save above code as a ps1 file
  • After running above script as a administrator in powershell make sure to give an

    iisreset

Hope it helps some of your problems.

Access Propert Bag in Sharepoint

There are multiple ways to access Property bag settings. As discussed in my previous post deploy appropriate property bag solution onto your farm to deal with UI version.

3 ways to access Property bag settings:

  • UI Version
  • SharePoint Designer
  • Programatically
  • UI Version:

    Using SharePoint Designer

    (i). Open the site in SP Designer 2010 and click on Site Options.
    (ii). Under Parameters, click on Add and Start Adding Key/Value PairsDesigner1

    Programatically

    To read this MyKey value, just use the below code.

    SPSite siteCollection = new SPSite("https://jagadeesh4sp.wordpress.com");
    SPWeb website = mySite.RootWeb;
    string MyValue = website.AllProperties["MyKey"]);
    

    Use the below code to set the property bags Programatically

    SPSite siteCollection = new SPSite("https://jagadeesh4sp.wordpress.com");
    SPWeb website = mySite.RootWeb;
    website.Properties.Add("MyKey", "MyValue");
    website.Properties.Update
    

    – Property bag Extension class

    public static class PropertyBagExtension
    {
     
        public static void AddProperty(this SPWeb web, string key, string value)
        {
            web.AllowUnsafeUpdates = true;
            web.Properties[key] = value;
            web.AllProperties[key] = value;
            web.Update();
            web.Properties.Update();
        }
     
     
        public static void RemoveProperty(this SPWeb web, string key)
        {
            web.AllowUnsafeUpdates = true;
            web.AllProperties.Remove(key);
            web.Properties[key] = null;
            web.Update();
            web.Properties.Update();
        }
     
     
        public static string GetPropertyValue(this SPWeb web, string key)
        {
            if (web.AllProperties.ContainsKey(key))
                return web.AllProperties[key].ToString();
     
            return null;
        }
    }
    

    Hope it helps some of you folks……

    Property Bags for SharePoint

    Property Bags enables the developers to add properties to the SharePoint objects like

    a. Farm (SPFarm class)
    b. Web application (SPWebApplication class)
    c. Site collection (SPSite class)
    d. Site (SPWeb class)
    e. List (SPList class)

    Using Property Bags, developers can avoid storing Key/Value pairs in Web.Config or at some other location. Internally, Property bags are implemented as a hash table of property names and values.

    We can set the Property Bag values using two ways:
    a.CodePlex Solution for MOSS 2007
    MOSS2007
    b.CodePlex Solution for SP 2010
    SP2010
    c.CodePlex Solution for SP 2013
    SP2013

    Brief Description

    SharePoint Property Bag offers developers to store configurations settings at different levels of the SharePoint hierarchy outside of the application itself.

    Features

    1. The SharePoint Property Bag Settings includes a hierarchical configuration manager that can safely store and retrieve configuration settings at the following levels:

    *Farm (SPFarm class)
    *Web application (SPWebApplication class)
    *Site collection (SPSite class)
    *Site (SPWeb class)
    *List (SPList class)
    2. Import and Export Property bags
    3. Access Property bags from Central Administration or Site Settings
    4. Encrypting property bag value

    Related Resources

    The Configuration Manager
    Managing Custom Configuration Options for a SharePoint Application