SharePoint 2013 Fixes for IE11 Incompatibility Issues

IE11 has incompatibility issues with SharePoint 2013, mostly due to the fact that IE specific SharePoint OOTB scripts use JavaScript methods and properties that have been deprecated in IE11.

Some common ones include:

  • Using .attachEvent() methods instead of .addEventListener()
  • Using document.body.all property instead of document.getElementById()

This can be resolved by forcing IE10 compatibility mode using <meta http-equiv=”X-UA-Compatible” content=”IE=10″ />. However, if you wanted to utilize IE-edge, we can fix the errors using the JavaScript below.

Continue reading

Advertisements

Microsoft Flow Approval with Delegation

Microsoft Flow has Approval actions, which allows you to send an approval email to 1 or more approvers to get their feedback, and pauses the flow while it waits for it.

However, there is no built-in delegation, so in cases where an approval is pending, and the approver(s) are not available, it stays stuck indefinitely waiting until the set approver(s) action it.

We can build a simple delegation mechanism into our Flow to try to alleviate this issue, where after a 1 week period, the approval gets “delegated” to someone else to action.

MS Flow Approval Delegation - Overview.png

Continue reading

Updating SharePoint Online Document Set in Microsoft Flow (including Taxonomy Field)

This is a follow up from my previous post onĀ Creating SharePoint Online Document Set in Microsoft Flow.

We’ve created the document set, and now we want to update some of the properties for the document set, one of which is a single value taxonomy field.

Assuming add-in only authentication has been set up and the access token has been obtained with a HTTP action and parsed into JSON, as per the previous blog post.

We now have actions after creating our document set to update the document set.

MS Flow Update Doc Set - Overview.png

Continue reading

Creating SharePoint Online Document Set in Microsoft Flow

As of the time of writing this, Microsoft Flow does not include any SharePoint connector actions to create a document set in a document library, which is quite inconvenient.

Instead, we are left to deal with this using SharePoint’s REST API, which is not straightforward and proves to have a few gotchas to watch out for.

This is the overview of a Flow that will create a new document set in the Documents library, on trigger from a list item, just for the sake of a demo.

MS Flow Create Doc Set - Overview.png

We will go through each action step by step below.

Continue reading

Getting Document URL using JSOM

To get the URL of current list item / document using JSOM, when in the EditForm.aspx page:

var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getById(_spPageContextInfo.pageListId);
var listItem = list.getItemById(parseInt(GetUrlKeyValue('ID')));

context.load(listItem);

context.executeQueryAsync(
    function () {
        $fileRef = listItem.get_item("FileRef");
        $urlField.val($fileRef);
    }
);

Uploading Files to SharePoint Master Page Gallery using PowerShell

PowerShell script below uploads a CSS and JS file to the Master Page Gallery, assuming the files are in the “Files” subfolder from where the script is executed, and existing files in SharePoint will be overwritten.

Param(
    [string]$siteUrl 
)

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) 
{
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
    write-host "Added SharePoint PowerShell snap-in" -ForegroundColor yellow
}

function Get-PSScriptRoot
{
    try
    {
        $scriptRoot = Get-Variable -Name PSScriptRoot -ValueOnly -ErrorAction Stop
    }
    catch
    {
        $scriptRoot = Split-Path $script:MyInvocation.MyCommand.Path
    }

    Write-Output $scriptRoot 
}

try
{
    $site = Get-SPSite $siteUrl
    $web = $site.RootWeb
    $list = $web.GetCatalog(116)
    $scriptPath = Get-PSScriptRoot

    # Upload CSS
    Write-Host "Uploading styles.css..." -NoNewLine
    $file = Get-ChildItem $scriptPath\Files\styles.css
    $spFile = $list.RootFolder.Files.Add("_catalogs/masterpage/css/styles.css", $file.OpenRead(), $true)
    $spFile.Publish("Uploaded from PowerShell")
    Write-Host "Done" -ForegroundColor Green
    
    Write-Host "Uploading scripts.js..." -NoNewLine
    $file = Get-ChildItem $scriptPath\Files\scripts.js
    $spFile = $list.RootFolder.Files.Add("_catalogs/masterpage/js/scripts.js", $file.OpenRead(), $true)
    $spFile.Publish("Uploaded from PowerShell")
    Write-Host "Done" -ForegroundColor Green
}
catch
{
    Write-Host "Failed: " $_.Exception.Message -ForegroundColor Red
    Write-Host $_.Exception.StackTrace -ForegroundColor Red
}