SharePointRoot


1 Comment

SharePoint Search Results with DateTime field refiner

When configuring a SEARCH RESULTS page, you can include any of your own custom columns as ‘refiners’.   These show on the side of the results, allowing users to filter down the results.

When you choose a field as a refiner, the data shown will depend on the type of the field.      Eg.  TEXT fields, will just show as the item values

image

When using a DATE field – for some reason, there’s a nasty symptom that doesn’t show the values correctly !

This symptom was also highlighted and blogged by Simon Doy.

WHY ?    The field is showing as 2,012 and 2,013 ??

My refiner is doing the same thing – compared to the Out Of The Box Created field :

image

RESOLUTION

I’m happy to report that there’s a very simple fix – and it’s related to the NAME of the managed property you create.

In my example :

  • DON’T name the property as “STaRCreatedDateTime”
  • Instead – it should be “STaRCreatedDateTimeOWSDATE

There’s some SharePoint JavaScript code that looks for the ‘type’ of the field – within the tail of the field name.    Sure enough – it works !

image

Thanks to SIMON for the tips and investigation – his blog goes into a lot of depth, with a custom refiner to change the look/feel.

It was this tip that saved the day :

image

Thanks Eman !      (Credit where credit is due)

:-)


1 Comment

Show status image in SharePoint column

Recently, I was discussing a clever trick with a colleague, for showing HTML in a SharePoint column.  

For SP2003 and SP2007, you needed to include some additional JavaScript (TEXT2HTML / examples) – but with SharePoint 2010 + 2013, you can do it using a calculated column.

Source column : Priority

Firstly, we need to add a column that we’ll use at the ‘checker’ column – this might be something like a STATUS column, or % COMPLETE, or PRIORITY.

  • Create Column : Priority
  • Type : Number

image

Add some List Data

Just add a few items to the list – and pick some priorities.

image

You can do whatever VIEWS, or SORTING or GROUPING – whatever…!

Find some images

Use your favourite search engine to look up some status images – I found a cool set here (more instructions here) :

image

Save these images locally – and upload to your SharePoint site – eg. SiteAssets, or Style Library.  I’ve loaded mine into an “IMG” folder.

Eg.   /Style Library/IMG/red.png

Calculated column

We can now do the magic + fun bit.

  • Create a calculated column : Indicator
  • Type : Calculated
  • Formula :

=”<DIV><img src='” & IF(Priority=1, “/Style Library/IMG/red.png”, IF(Priority=2,”/Style Library/IMG/yellow.png”, IF(Priority=3,”/Style Library/IMG/green.png”, IF(Priority=4,”/Style Library/IMG/blue.png”)))) & “‘></DIV>”

This is essentially doing the following :

  • If Status = 1, put an IMG tag for RED
  • If Status = 2, put an IMG tag for YELLOW
  • etc

NB.  The way that the formula works is like EXCEL :

  • IF (condition, TRUE, FALSE)

This method (above) is nesting these :

  • IF (condition1, IMAGE, IF (condition2, IMAGE, IF (condition3, IMAGE, IMAGE ) ) )

Click back to your list to view your column :

image

What the !!?!    It’s just showing HTML !!

:-(

The UberMagic Tip

You’d be thinking that this is a “dud” tip – and you’ll need some “TEXT2HTML” JavaScript and so on – which would be annoying.

But no – the amazingly simple tip is this :

  • Change the return type to be a NUMBER.

Yep.   If defies logic – and doesn’t make sense – might even be a BUG !

But – it works.

image

Take a bow

If you’ve done the steps correctly, it should look like this :

image

Too easy – right !!?!

** You might need to include the ‘site collection’ prefix within the formula – pro tip !

=”<DIV><img src='” & IF(Priority=1, “/sites/SC1/Style Library/IMG/red.png”, IF(Priority=2,”/sites/SC1/Style Library/IMG/yellow.png”, IF(Priority=3,”/sites/SC1/Style Library/IMG/green.png”, IF(Priority=4,”/sites/SC1/Style Library/IMG/blue.png”)))) & “‘></DIV>”

Next ideas

Check this blog for some other renditions – very cool !

http://sharepoint.alanchai.com/2012/05/conditional-formatting-for-list-sp2010.html

image

image

Let me know if you like this tip – my buddy DanCol was #MindBlown over this one !

:-)


Leave a comment

Copy files to every server (SharePoint)

Even with the ‘new era’ being Office 365, sometimes (!) we have to deal with an on-premises SharePoint farm – often with many servers.

The recent environment I was upgrading has over a dozen servers – and we had a need to copy a file to EVERY server.

This was simply a PDF icon image – but a pain-in-the-butt to copy to lots of locations.

The solution was to define an XML file with a list of servers, and some PowerShell to do the copying.

Make sure to save both files to the same folder – and the image file (in this situation).

SERVERS_LIST.XML (contents)

<servers>

<server>SPWB101</server>

<server>SPWB102</server>

<server>SPAP101</server>

<server>SPSSRS01</server>

</servers>

The PowerShell script does the following :

  • Open the XML file
  • Do a “Foreach” for the servers
  • Define the path for the file (destination)
  • Do a “Copy-Item” command – to each \\SERVER\C$\path

POWERSHELL

$xml = [xml] (Get-Content (resolve-path .\SERVERS_LIST.xml))

$currentPath = (resolve-path .\pdficon_small.png)

$servers = $xml.Servers.Server

$servers | % {

      $server = $_

      $path = “\\$server\C$\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES\icpdf.png”

      Copy-Item $currentPath $path

}

 

This is a great option for a quick “deploy to every server” – as a scripted solution.

Hope this can be helpful / useful for your environment !

:-)


Leave a comment

Open in new window – MySites

Within SharePoint 2013, there is a navigation menu with the “About Me” link – which re-directs to MySites.

We have a customer request that asked if this link could be changed to display in a new tab.

image

After some investigation into the HTML, and markup within the Master Page, I determined the following :

There is a control called WELCOME.ASCX for this piece – in the master page :

<%@ Register TagPrefix=”wssuc” TagName=”Welcome” src=”~/_controltemplates/15/Welcome.ascx” %>

This loads a bunch of HTML and JavaScript – with the actual click-link being executed by a function called :

  • STSNavigate2

image

THIS function is actually within INIT.JS – and changes the window.location.href.

image

So – HOW do you change this ??

The change I introduced does the following, using some JavaScript added to the Master Page :

  • Find the HTML hidden nodes used for the WELCOME menu
  • Determine the OnClick JavaScript function – using jQuery
  • Change this to be MY function
  • New function to do ‘open in new window’ for the URL

image

** The biggest problem I had was whether to use ExecuteOrDelayUntilScriptLoaded, and WHERE in the Master Page to put this.

In the end, I included this at the very BOTTOM of the Master Page – just before the closing BODY tag – you can see this in the screenshot above.

The functions included are :

  • STSNavigationNewWindow – new function called when user clicks on the link
  • ReplaceMenuFunction – just a string replace function
  • OpenInNewWindow – gets the existing text in the onmenuclick property – and change it
  • _changeTargetForHyperlinks – can list the specific item to change – and any others

Here’s the full text of the above ‘magic’ – hope it helps you – let me know if it does, I love to see/hear nice comments from other SharePoint’ers out there.

:-)

<script type=”text/javascript”>
    // this is the new function that does the stuff
    function STSNavigateNewWindow(a, b) {
        window.open(b, ‘_blank’);
    }

    //helper function to replace out the property
    function ReplaceMenuFunction(a) {
        return a.replace(‘STSNavigate2′, ‘STSNavigateNewWindow’);
    }

    //set the JS function for specific fields
    function OpenInNewWindow(idValue) {
        var jqControl = $(idValue);
        var oldFunctionRef = jqControl.attr(‘onmenuclick’);
        if (oldFunctionRef) {
            var newFunctionRef = ReplaceMenuFunction(oldFunctionRef);
            jqControl.attr(‘onmenuclick’, newFunctionRef);
        }
    }

    function _changeTargetForHyperlinks() {
        OpenInNewWindow(‘#ID_AboutMe’);
    }

    _spBodyOnLoadFunctionNames.push(‘_changeTargetForHyperlinks’);

</script>

~wookie…


Leave a comment

Cannot click ‘connect’ for Azure VM

In order to try out the new AZURE portal site (portal.azure.com), as well as Windows 10, I’ve created myself a VM – entitled “Wookie10”.

Within the portal though, I’m unable to “connect” to the VM – the button is disabled !?

image

It turns out that the provisioning of a VM within Azure (for a Windows ‘client’ machine – not Windows Server) does not add the Endpoints to allow for this.

The steps to resolve this are :

(1) Click on the VM you’re using – click SETTINGS

(2) Choose ENDPOINTS

(3) Click [+ ADD]

image

(3) Enter the following :

** Make sure to keep the PRIVATE PORT = 3389

image

NB. Just choose a random port :

image

(4) Click OK – and wait a few moments – check your “Notifications”

image

You might need to close the ‘blades’ – and then re-select it.

If you’ve done it correctly, you should be able to do REMOTE DESKTOP :

image

This will save an RDP file – and you’ll be able to connect….

Thanks Azure !

:-)


Leave a comment

SharePoint Publishing Feature – Access Denied error for FULL CONTROL user

Within our SharePoint 2013 farm, we have a number of users who are ADMIN – and others who are simply FULL CONTROL.

We’re finding that we get an error when these ‘FULL CONTROL’ users activate the SharePoint Publishing feature.

Sorry, you don’t have access to this page

image

When looking with LOGS, there are some error messages related :

System.Runtime.InteropServices.COMException: <nativehr>0x81070211</nativehr><nativestack></nativestack>Cannot open file “_catalogs/masterpage/__DeviceChannelMappings.aspx

SPRequest.GetMetadataForUrl: UserPrincipalName=i:0).w|s-1-5-21-1159821373-1672690008-2013803672-278888, AppPrincipalName= ,bstrUrl=/DeviceChannels

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

ISSUE –> Device Channels

It would appear that these FULL CONTROL users do not have access to the library at the root site, that controls ‘DeviceChannels’.

Even if these aren’t being used within your farm, it’s part of the provisioning code for the Publishing feature.    If that errors, then it all causes the ‘access denied’.

When doing ‘check permissions’ within the library, it shows as this :

https://server/DeviceChannels

image

RESOLUTION

Within the library, choose to “GRANT PERMISSIONS” to the specific user – or group.    For some reason, this library has ‘unique permissions’ – it could be a consideration to “re-inherit” permissions.  

Or – grant read-only permissions to EVERYONE.

image

After you’ve done this, you will find that the “FULL CONTROL” users can now activate the PUBLISHING feature.

:-)


Leave a comment

List all Nintex Workflows

When needing to list the workflows within a SharePoint farm, there is a command that can be used from the Nintex SDK :

nwadmin -o FindWorkflows

But – the format (output) of the workflow list is a little tricky to use.   

You simply need to view the lines with “- -“ and “- – – -“ at the start of the line.

image

I have a newer script that writes out ONE line for each workflow – easy when you need to have a definitive “to do” list of SITE workflows, and LIST workflows.

Here’s the new output :

image

This can then be loaded into EXCEL – and sorted.

The script is as follows – just a PowerShelll function that processes the output from the NWADMIN command :

image

If you’d like to use the script – here it is :

function FormatListOfWorkflows
{
    # build the credential object
    $secpasswd = ConvertTo-SecureString $args[1] -AsPlainText -Force
    $credential = New-Object System.Management.Automation.PSCredential($args[0],$secpasswd);

    # find all the workflows and store them in a variable
    $foundworkflows = nwadmin -o FindWorkflows

    foreach($line in $foundworkflows)
    {
        if($line.StartsWith(“Active at “))
        {
            # get the site url
            $site = $line.Replace(“Active at “,””);
        }
        if($line.StartsWith(“– “))
        {
            # get the list name
            $list = $line.Replace(“– “,””);
            #make sure to NOT have &amp; error
            $list = $list.Replace(“&amp;”, “&”)
        }
        if($line.StartsWith(“—- “))
        {
            $loopCount = $loopCount + 1
            $totalCount = $totalCount + 1

            # get the workflow name
            $workflowname = $line.Replace(“—- “,””);

            #get the workflow – exported
            if($list -eq “Site workflow”)
            {
                $s = “SITE WORKFLOW :       SITE > ” + $site + ”    WORKFLOW > ” + $workflowname
                echo $s
            }
            elseif($list -eq “Reusable workflow template”)
            {
                $s = “REUSABLE WORKFLOW TEMPLATE :       SITE > ” + $site + ”    WORKFLOW > ” + $workflowname
                echo $s
            }
            elseif($list -eq “Site collection reusable workflow template”)
            {
                $s = “SITE COLLECTION REUSABLE WORKFLOW TEMPLATE :       SITE > ” + $site + ”    WORKFLOW > ” + $workflowname
                echo $s
            }
            else
            {
                $s = “LIST WORKFLOW :       SITE > ” + $site + ”    LIST > ” + $workflowname + ”    WORKFLOW > ” + $workflowname
                echo $s
            }
        }
    }
}

$userName = ‘DOMAIN\username’
$userPassword = ‘password’

FormatListOfWorkflows $userName $userPassword

 

You could change the text further if you need, perhaps include “|” between columns, and can easily create columns when importing into EXCEL.

Good luck – and happy NINTEX’ing…

:-)

Follow

Get every new post delivered to your Inbox.

Join 30 other followers