Pre-Populate People Picker Value With Current User

Here is how you can set the current user into a person/group field for example on a NewForm.aspx page.
All you need is JQuery and a Content Editor Web Part (CEWP) on the NewForm.aspx page.

Just change the name of your People Picker field in line 4 below.



SharePoint Url Query Parameters

Today I’m posting some useful URL query parameters for SharePoint:

  • Web Part Maintenance Page
    http://siteUrl?contents=1
  • User Information List
    http://SC-Url/_catalogs/users/simple.aspx
    http://SC-Url/_catalogs/users/detail.aspx
  • Open Page in edit mode
    http://siteUrl?ControlMode=Edit&DisplayMode=Design
  • Quick Deploy List (Hidden)
    http://SC-Url/Quick%20Deploy%20Items/AllItems.aspx
  • Taxonomy List (Hidden)
    http://SC-Url/Lists/TaxonomyHiddenList/AllItems.aspx
  • Nintex Workflow History List (Hidden)
    http://SC-Url/Lists/NintexWorkflowHistory/AllItems.aspx
  • Get the version of the SharePoint server
    http://SC-Url/_vti_pvt/Service.cnf
  • Save site as a template
    http://siteUrl/_layouts/savetmpl.aspx
  • Sign in as a different user
    http://SC-Url/_layouts/closeConnection.aspx?loginasanotheruser=true
  • Application page for registering SharePoint Apps
    http://SC-Url/_layouts/appregnew.aspx
  • Enable SharePoint Designer
    http://SC-Url/_layouts/SharePointDesignerSettings.aspx
  • Welcome Page Setting
    http://SC-Url/_layouts/AreaWelcomePage.aspx
  • Force displaying the user profile in the site collection
    http://SC-Url/_layouts/userdisp.aspx?id={UserID}&Force=True
  • OfficeWebApp “Ribbon.Read” has not been made available for this page or does not exist

    If you receive following error:

    “The Ribbon Tab with id: “Ribbon.Read” has not been made available for this page or does not exist.”

    while trying to create a new office document by clicking new document and selecting one of the office documents:

    OfficeWebApp NewDocument

    Then you should try to rebind your SharePoint WOPI bindings to your OfficeWebApp Server.

    To do this, open the SharePoint PowerShell management shell on one of your SharePoint server and run following commands:

    # Loading the SharePoint PowerShell Snapin if not already loaded
    if ((Get-PsSnapin | ?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null)
    {
       $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    }
    
    Remove-SPWOPIBinding -All:$true
    New-SPWOPIBinding –ServerName ""
    
    

    If you dont’t know the FQMN of the OfficeWebApp server, you can get it by opening following URL in the browser:

    https://<OfficeWebAppServerName>/hosting/discovery

    Here you will get the WOPI discovery XML file in which you can see the URL of your Office WebApp server.

    For more information on the PowerShell commands, please refer to following technet article:
    Windows PowerShell for Office Web Apps (SharePoint 2013)

    WOPI – Web Application Open Platform Interface
    FQMN – Fully Qualified Machine Name
    URL – Uniform Resource Locator

    Adieu InfoPath:-(

    Microsoft announced that they’re retiring the development of the product InfoPath.
    No new version of InfoPath will be released in the future. So the last version is InfoPath 2013.
    But Microsoft is investing effort in a new forms technology which will better integrate SharePoint, Access and Word.
    MS Office Blog Post

    So what about product support?
    Expiration of the Extended Support (according to information on Microsofts page)

    • InfoPath 2003 will be supported until April 2014.
    • InfoPath 2007 will be supported until October 2017.
    • InfoPath 2010 will be supported until October 2020.
    • InfoPath 2013 will be supported until October 2023.

     
    More details about the roadmap of the new form technology will be presented in March on the SharePoint Conference in Las Vegas.

    PowerShell Error: Microsoft SharePoint is not supported with version 4.0.30319.1008 of the Microsoft .Net Runtime

    For some reason I got following error as I tried to run a PowerShell command:

    “Microsoft SharePoint is not supported with version 4.0.30319.1008 of the Microsoft .Net Runtime.”

    Luckily this one was already documented by Microsoft in following KB article: http://support.microsoft.com/kb/2796733

    To work around this issue, change the Target field value for SharePoint 2010 Management Shell. To do this, follow these steps:

  • Click Start, and then right-click SharePoint 2010 Management Shell.
  • Click Properties.
  • Click the Shortcut tab in the SharePoint 2010 Management Shell Properties window.
  • Input the following value in the Target field:
    C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit ” & ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1′”
  • Now the SharePoint Management Shell will open with the correct Version.

    If you are using PowerGUI then you should check the config file of the script editor.
    The normal location path is following: C:\Program Files (x86)\PowerGUI

    Look for the appropriate config file: ScriptEditor.exe.config

    If you see the entry with supportedRunTime version=”v4.0″, just delete this line or comment it out.

    PowerGUI_Config

    Now restart PowerGUI and try again to run your script/command.

    Clear SharePoint System Cache

    If you have trouble with e.g. your SharePoint Workflow Timer Job, which seem to stuck in state “Running” for many hours, then it might be helpful to clear the file system cache on your frontend servers.
    To do so, follow the steps below on all of your servers, which are running the Windows SharePoint Services Timer Service:

  • Open the Services window (Start->Run->Services.msc->Enter) and stop the “SharePoint 2010 Timer” service.
  • If you use a service account for this service, I would also recommend to reenter the password.
    Right click onto the SharePoint 2010 Timer Service, then on properties and in the “Log On” tab reenter the password an press the “Apply” button.
  • Now go to the directory C:\ProgramData\Microsoft\SharePoint\Config.
    Here you may see 2 folders with GUIDs.
    We need the one where you see alot of XML-Files and ONE Cache.ini file.
  • Backup this GUID folder to be on the safe side.
    Now be careful:
  • Delete ONLY all the XML-files in the GUID folder:
    DO NOT DELETE THE GUID FOLDER ITSELF, OR THE CACHE.INI FILE IN IT!
    Don’t worry, these XML-files will be created automatically again in the next steps below.
  • Now open the Cache.ini file. Here you will only see a number in it.
    Replace this number by typing a 1.
  • Save the Cache.ini file and close it.
  • Start the SharePoint 2010 Timer Service again.
  • You will now see that the cache will be recreated by automatically recreated XML-files in the folder. This will take some minutes to complete.
    Do these steps above on the other frontend servers as well.

    Timeout When Publishing InfoPath Form Template

    When you ever run into a timeout issue when publishing large InfoPath forms to the server, then you should add/change some parameters in the web.config of the SharePoint WebApplication.

    Usually this file is located here: C:\inetpub\wwwroot\wss\VirtualDirectories\<Portnumber>
    Make sure that you make a backup of this file before you change anything in there.

    
     ...
      
        
          
        
      
    ...
    
    

    maxRequestLength
    The maximum request size in kilobytes. The default size is 4096 KB (4 MB).
    The maxRequestLength property specifies the limit for the buffering threshold of the input stream.

    executionTimeout
    A TimeSpan value that indicates the allowed execution time for the request. The default is 110 seconds.
    The executionTimeout property indicates the maximum number of seconds a request is allowed to execute before being automatically shut down by ASP.NET.

    Another place in the web.config file is somewhere below the section <securityPolicy>.
    There you should also see an <httpRuntime> entry which you can update, too.

    InfoPath 2010 Get Manager Of Current User

    Displaying the current user in an InfoPath 2010 form is not that tough, but how about the manager of the current user?
    Well in this post i will show you how you can do that with rules and a SharePoint web service.

    First of all put 2 fields of type Person/Group Picker into your form.
    Form

    I renamed the 2 groups in the datafields like shown below (CurrentUser and Manager):

    DataFields

    Now add a new data connection to receive data from a SOAP web service to your form and enter the URL to the Web service
    http(s)://YourSiteURL/_vti_bin/UserProfileService.asmx?WSDL
    In the next screen select the method GetUserProfileByName and finish the wizard.

    GetUserProfileByName

    Now lets go to the interesting part.
    Open the form load rules task pane from the ribbon:

    FormLoad

    Add following Rules now:

    Rule 1
    Here we set the AccountName for which the web service will receive the data for.
    As the AccountName value we can use the built in function userName()

    click to enlarge
    RuleAction1

    Rule 2
    As a second rule use the Query for data action and select the data connection of the web service which we configured before.
    So we will receive the UserProfile information of the current user (see picture above).

    Rule 3
    This rule is the important one where we will set the AccountName for the web service query in order to
    receive the profile properties of the manager of the current user:

    click to enlarge
    RuleAction3

    Rule 4
    This one is just executing the web service but this time with the manager’s account name (see picture in Rule 1).

    Rules 5-7
    These rules are setting the values for the Person/Group Picker of the manager.

    click to enlarge
    RuleAction5-7

    So now when you open the form, the name of the manager is automatically set in the person picker field.


    Below you will find some more properties which you can filter for in your InfoPath rules e.g. Value[Name=”PropertyName”]

    So in the above condition you can replace PropertyName with one of these below:

  • AccountName
  • FirstName
  • LastName
  • PreferredName
  • WorkPhone
  • Office
  • Department
  • Title
  • Manager
  • AboutMe
  • PersonalSpace
  • PictureURL
  • UserName
  • QuickLinks
  • WebSite
  • PublicSiteRedirect
  • Assistant
  • WorkEmail
  • CellPhone
  • Fax
  • HomePhone
  • SPS-Dotted-line
  • SPS-Peers
  • SPS-Responsibility
  • SPS-Skills
  • SPS-PastProjects
  • SPS-Interests
  • SPS-School
  • SPS-SipAddress
  • SPS-Birthday
  • SPS-MySiteUpgrade
  • SPS-DontSuggestList
  • SPS-ProxyAddresses
  • SPS-HireDate
  • SPS-LastColleagueAdded
  • SPS-OWAUrl
  • SPS-ResourceAccountName
  • SPS-MasterAccountName
  • SharePoint / Nintex Workflow Status Codes

    Here are the SharePoint workflow status codes which you can reference in SharePoint to filter your list/library view or use them in the workflow itself.

  • 0 = Not Started
  • 1 = Failed on Start
  • 2 = In Progress
  • 3 = Error Occurred
  • 4 = Canceled
  • 5 = Completed
  • 6 = Failed on Start (retrying)
  • 7 = Error Occurred (retrying)
  • 15 = Canceled
  • 16 = Approved
  • 17 = Rejected
  • I think the numbers between 8-14 are reserved only for SharePoints internal use.

    If you start the workflow for the first time, it will create automatically a new column with the workflowname, in which it then inserts the appropriate codes above. You can see this by opening the library in the DataSheet view:

    click to enlarge
    WFStatusCodes_1

    WFStatusCodes_2

    This workflow status column is now also shown as part of the view. So you can filter for it by entering one of the status codes above (not the text).

    WFStatusCodes_3

    Another possible scenario would be to use the codes in one of the workflow actions directly, for instance in Nintex Workflow Actions:

    WFStatusCodes_4

    Activate Publishing Feature With PowerShell

    Maybe you also struggled about this, too. Trying to activate the SharePoint Publishing feature results in an error and it’s not possible to activate it over the SharePoint UI.
    In this case the PowerShell script below will do the activation. The script will also update a property of the web, indicating that the feature is beeing active.

    If you wish, you can check the PropertyBag of the Web with SharePoint Manager. It will look like this:

    ForceActivatePublishingFeature_Blog

    ##
    ## Force activating Publishing feature on web level
    ##
    
    # Loading the SharePoint PowerShell Snapin if not already loaded
    if ((Get-PsSnapin | ?{$_.Name -eq "Microsoft.SharePoint.PowerShell"})-eq $null)
    {
       $PSSnapin = Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
    }
     
    # define variables  
    $targetWebUrl = "http://myFarmURL/SubWeb"
    
    # Force feature activation
    Enable-SPFeature -Identity "PublishingWeb" -Url $targetWebUrl -Force
    
    # Sometimes, somehow the web property is still displayed as "False" and needs to be set to "True"
    $myWeb = Get-SPWeb $targetWebUrl
    $myWeb.AllProperties["__PublishingFeatureActivated"] = "True"  
    $myWeb.Update()