SharePointRoot


2 Comments

Video Player for SharePoint 2013 and Office 365

When needing to include some media content for a SharePoint 2013 site, there is an out-of-the-box video player that uses the new HTML5 VIDEO tag.

NB. I’m using the Public-Facing Anonymous website that is part of Office 365.

Choose a video :

image

Video player :

image

This is ‘nice’ – but is a little lacking – and not a good solution for a public facing site (anonymous) – and doesn’t play on an iPhone (FAIL !)

Alternative HTML5 video player

After some looking around, the best solution I’ve found is an extension to the HTML5 VIDEO tag – making use of the very-awesome, open-source – AND free – VIDEO.JS plug-in (just check the website link for a sample).

This uses some JavaScript to include some controls – and – works across browser, and most importantly, on an iPad/iPhone.

The steps I took were as follows :

(1) Get the files for VIDEO.JS 

I chose to download, and save these to STYLE LIBRARY – just to have them hosted on my site – rather than use the CDN – right-click and SAVE these files :

  1. video.js    (JavaScript)
  2. video-js.css    (CSS)
  3. video-js.swf    (Flash Plug-in)

 

Upload the above files to STYLE LIBRARY.

(2) Load the files to SharePoint 2013

You’ll also need to upload the following :

  • Video file – well, derrrr…       I’m using an MP4
  • JPG for the preview image – known as the ‘poster’ for VIDEO.JS

I put these last few files into SITE ASSETS

(3) Add the SCRIPT for the video player

On the page you want to show the video, include an “Embed Code” webpart.

Here’s the tags you need for the JS, CSS and SWF :

<link href=”/Style%20Library/video-js.css” rel=”stylesheet”></link>

<script type=”text/javascript” src=”/Style%20Library/video.js”></script>

<script>

videojs.options.flash.swf = “/Style%20Library/video-js.swf”

</script>

(4) Include the VIDEO tag

I had to tweak and fine-tune the examples from the site for VIDEO.JS.

With regard to the VIDEO tag for SharePoint – or more specifically, the “Embed Code” dialog/editor strips out some tags/text – specifically the ‘controls’ tag.

HTML5 allows you to have the attribute controls which implies a default of ‘True’.  

SharePoint will remove that – so you have to explicitly set controls=’true’.

The other piece was the surrounding DIV to make sure that the ‘overflow’ was hidden – otherwise, the Safari browser on iOS will display the window the same size as the original video dimensions – irrespective of the size entered.

Here’s the HTML you’ll need :

<div style=”width:576;height:324;overflow-x:hidden;overflow-y:hidden;”>

<video id=”SPvideo” class=”video-js vjs-default-skin vjs-big-play-centered” preload=”auto” data-setup=”{‘example_option':true}” controls=”true” poster=”/SiteAssets/VideoPreviewFrame.jpg” height=”324” width=”576“>
<source type=”video/mp4″ src=”/SiteAssets/MyCoolVideo.mp4“>
</video>

</div>

(5)  Change if you need

Of course, you can tweak and fine-tune as you need – with regard to :

  • Width + Height – make the outer DIV the same as the VIDEO tag (obviously)
  • Poster – I just did a screenshot of the video (full screen), and resized it to be the same width/height – 576×324 for my example
  • The URL to the video of course – you can try with a WEBM format, or whichever you like, according to the HTML5 VIDEO tag.
  • CSS and other bits
  • Any other VIDEO.JS extensions and such – check the DOCS + API reference.

(6) The final product

After I’d implemented the above, the player looks like this :

image

This is within an anonymous site on Office365 – just make sure you ‘publish’ the files for CSS, JS and SWF.

The player on iOS shows the preview image, and then uses the iPhone video player.

Good luck – let me know if this helps – pls. leave me a comment.

:-)


Leave a comment

DataVisualization.Charting using ASP.NET and C#

As part of a recent SharePoint project, we have been needing to generate graphs/charts for inclusion on a webpage – as well as via code to save and include in a Microsoft Word document (DOCX).

The best option we found was the Microsoft .NET charting controls :

System.Web.UI.DataVisualization.Charting

To get this working within an ASP.NET project, I had to source information from a few blog posts – and it was a little tricky – so I thought I’d blog about it here.

(1) Within your Visual Studio WebApp Project, add a reference to the required DLL’s :

System.Web.DataVisualization

image

(2) Add an IMAGE placeholder control to your ASP.NET markup :

<asp:Image ID=”imgChart” runat=”server” />

(3) Within code, include the *using* statement, and then the necessary code for charting.   

using System.Web.UI.DataVisualization.Charting;

(4) The trick I found was to made sure the chart control did a ‘RenderControl’ – and then you can use the CurrentImageLocation reference.

private void ShowChart()
{
    // set up some data
    var xvals = new[]
    {
        new DateTime(2012, 4, 4),
        new DateTime(2012, 4, 5),
        new DateTime(2012, 4, 6),
        new DateTime(2012, 4, 7)
    };

    var yvals = new[] { 1,3,7,12 };

    // create the chart
    var chart = new Chart();
    chart.Height = 600;
    chart.Width = 600;
    chart.RenderType = RenderType.ImageTag;

    //set the chart properties
    var chartArea = new ChartArea();
    chartArea.AxisX.LabelStyle.Format = “dd/MMM\nhh:mm”;
    chartArea.AxisX.MajorGrid.LineColor = Color.LightGray;
    chartArea.AxisY.MajorGrid.LineColor = Color.LightGray;
    chartArea.AxisX.LabelStyle.Font = new Font(“Consolas”, 8);
    chartArea.AxisY.LabelStyle.Font = new Font(“Consolas”, 8);
    chart.ChartAreas.Add(chartArea);

    var series = new Series();
    series.Name = “Series1″;
    series.ChartType = SeriesChartType.FastLine;
    series.XValueType = ChartValueType.DateTime;
    chart.Series.Add(series);

    // bind the datapoints
    chart.Series["Series1"].Points.DataBindXY(xvals, yvals);

    // render to a HTML writer
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    chart.RenderControl(hw);

    //can now grab the URL to the asp:image
    imgChart.ImageUrl = chart.CurrentImageLocation;

}

(5) Run the solution – and you should see the page like this :

image

** Many thanks to the TIM BARRASS for the following post for much of the details – was just the ‘ASP.NET’ aspect that I had to work out – his blogpost was using the Windows.Forms components.  

The bits in RED above are the main differences.

Creating a chart programmatically in C# using DataVisualization.Charting


Leave a comment

SharePoint Calculated Column value -329378600

When migrating to SharePoint 2013, there are some differences that may impact when checking calculated columns.

We had a list/library that was from SharePoint 2007.

In the following (complicated) example, the ‘end value’ was wrong :

=IF([Action 2 When]=””,””,IF(AND([Action 2 When]>=[Last Report Date],[Action 2 When]<=[Todays Date]),”Newly Late”,IF([Action 2 When]<[Last Report Date],”Still Late”,”On Time”)))

The value was being shown as :

;#-329378600

WTF ?

It turned out that this was an EXCEPTION code – and the formula was getting null’ed out somewhere along the line.

The answer was to make sure to put “space” in an empty value :

=IF([Action 2 When]=””,” “,IF(AND([Action 2 When]>=[Last Report Date],[Action 2 When]<=[Todays Date]),”Newly Late”,IF([Action 2 When]<[Last Report Date],”Still Late”,”On Time”)))

Very subtle different – but it seems to resolve the problem (!)

HTH.   :-)


2 Comments

Quick Data Load for SharePoint 2013 Custom List

With the new SharePoint 2013 custom list ‘Quick Edit’, Microsoft have removed the (very cool) DataSheet view – which used a Microsoft-Access ActiveX plug-in.

This would be for cross-browser compatibility – and other devices – but it’s left a bit of a gap with regard to editing multiple rows.

Specifically, when needing to upload rows and rows of data – such as from Microsoft Excel – case in point, with a spreadsheet I was emailed by a client.

There’s a simple step – using Microsoft Access 2013 (desktop tool).

Here’s the basics :

  • Create your SharePoint list – with the columns you need.
  • Eg.  Name, StateCode, Suburb (list of hotels for an InfoPath lookup)
  • Click on the “List Tab” and choose “Open with Access”

image

  • When prompted, choose to “Link to data” – NOT “Export a copy”

image

  • Flip back to your spreadsheet
  • Select the columns/rows
  • Right click – and hit “Copy” (or CTRL+C)

image

  • Back to Access
  • Highlight the cells – and click “Paste”

image

  • Takes a few seconds – and then the rows appear.

I’m using Office 365 – so takes a little longer – Melbourne –> Singapore – LOL !

image

  • Change over to SharePoint
  • Click F5 to refresh the page – too easy !

image

Hopefully that’s a useful tip for someone – cheers !


3 Comments

Sideloading of apps is not enabled on this site – Office 365

When creating an App for SharePoint 2013, there is a hidden ‘developer feature’ that must be turned on – otherwise, you will get this error (Visual Studio)

image

To turn this on for “on-prem” SharePoint 2013 – you simply need to do this :

Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://sp.contoso.com

(Thanks to Joe Rodgers for that tip)

But, of course, it’s trickier – as you can’t run a ‘local’ PowerShell command.

I found another blog post that explained how to activate a feature on SharePoint+Office365 – thanks Kanwartej Basrai.

Here’s the full script you need to run – to activate the “developer feature” for Office365 – and thus allow you to run custom coded App’s – phew !

============================================

Import-Module Microsoft.Online.SharePoint.Powershell

$developerFeature = “e374875e-06b6-11e0-b0fa-57f5dfd72085″

$siteUrl = https://MYTENANT.sharepoint.com
$userName = “admin@MYTENANT.onmicrosoft.com”
$password = ConvertTo-SecureString -String ‘MyPass@word1′ -AsPlainText -Force

[Microsoft.SharePoint.Client.ClientContext]$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)  

$clientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userName, $password)
$site = $clientContext.Site;    

$featureguid = new-object System.Guid $developerFeature    
$site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);

$clientContext.ExecuteQuery();     

 

=============================================

** Before you run the above script, you might have to install the ‘plug-in’ for remote connectivity – see here for info :

http://office.microsoft.com/en-au/sharepoint-help/set-up-the-sharepoint-online-management-shell-environment-HA102919087.aspx

And also – if you haven’t yet run any PowerShell commands from your local PC, make sure to “Run-As-Admin” when you open PowerShell – and execute THIS command :

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned​

Hope that helps – leave a comment if it did !

 

:-)


Leave a comment

Nintex Workflow – Error Converting Document (Conversion Job)

Within SharePoint 2010, it’s great to be able to convert a DOCX to PDF – or a bunch of other formats.

This uses the default “Word Automation Services” – which is a Service App as part of SharePoint 2010 (OOTB).

The Nintex Workflow action for “Convert Document” just needs a few parameters :

  • Source File + URL
  • File Type
  • Destination File + URL

clip_image002

However, I’ve been getting an error :

Error converting document. Conversion jobs did not complete. 1 jobs failed. 0 jobs cancelled.

An error has occurred in [WorkflowName].

Some digging about in the SharePoint Logs uncovered this gem :

Conversion jobs failed:  Input file: http://portal.dev.local/Shared%20Documents/TEST.docx; Conversion Id: 00000001-0001-1000-80a0-97d520f52b1d;

Error code: 6; Message: The file could not be downloaded from the input library due to a technical problem.  Please contact your system administrator.     (Build:23100)           

That’s not very helpful !!

BUT – there was another little tidbit – within the Event Viewer this time :

SQL Database ‘SP-Dev-PortalContent’ on SQL Server instance ‘SharePoint2010′ not found. Additional error information from SQL Server is included below.

Cannot open database “SP-Dev-PortalContent” requested by the login. The login failed.
Login failed for user ‘DEV\SP-Dev-Services’.

image

OOhhh – I think it’s a permissions problem.

When looking into SQL Server, it looks like the “Service Account” being used by the “Service App” didn’t have permission to the “Content DB”.

But – even after THAT – I’m getting another error :

There is a compatibility range mismatch between the Web server and database “SP-Dev-PortalContent”, and connections to the data have been blocked to due to this incompatibility.

This can happen when a content database has not been upgraded to be within the compatibility range of the Web server, or if the database has been upgraded to a higher level than the web server.

The Web server and the database must be upgraded to the same version and build level to return to compatibility range.

So – the next step was to grant “db_owner” permission

image

After doing that – I made sure to do an IISRESET – and then it would appear I’m “OK” with the permissions issue – and connecting to the Content DB.

I’m now getting a different error :

Error code: 65543; Message: The file could not be converted; it may be corrupt or otherwise invalid (the conversion process failed).

Please try opening the file in Microsoft Word, resaving it, and then resubmitting the file for conversion.

If this does not resolve the issue, contact your system administrator.

It would appear that there’s a regression issue/problem – after SP1 in SharePoint 2010 – which reset the “Word Automation Services” to run in SANDBOX mode.

There’s a great article on the connect.nintex.com site – explaining the steps required.

I made sure to run the following PowerShell commands :

$sp = Get-SPServiceApplication | where {$_.TypeName.Equals(“Word Automation Services”)} 

$sp.DisableSandbox = $true

$sp.Update()

And – that seemed to FIX the problem – after yet another IISRESET – finally !

** Thanks to Chris Buchanan for the final tip about another IISRESET.

Thanks a LOT SharePoint – doh !!

:-)


1 Comment

Document Information Panel error – proppanel.xsn + view2.xsl (invalid)

I was recently looking into a problem with a Document Information Panel – within Microsoft Word.

There was an error being shown as the document loaded :

Document Information Panel cannot open a new form.
The form cannot be opened. To fix this problem, contact the form designer.
Form template: http://spr/proppanel.xsn
Document Information Panel cannot open the following view: [CONTENT TYPE] Properties – Server
The following view file is not valid: view2.xsl
The .xsl file is not valid XSL.
xsl:choose must have at least one xsl:when child.

 image

Within my SharePoint feature, I was deploying a few custom columns – one of these was a CHOICE field :

<Field ID=”{a75f81c8-a860-4967-996a-0f7941b81119}” Name=”SenderLocation” Group=”SPR Columns” DisplayName=”Sender Location” Type=”Choice” FillInChoice=”TRUE” />

This was intended for a user to add the name of a “Sender Location” – I didn’t actually know the initial choices – so I didn’t include them – but the “FillInChoice” would allow them to add values over time.   

** NB. The fields works OK (in the DIP) if you don’t specify “FillInChoice” (default = false).   The DIP won’t error – just no choices selectable.

Here in lies the issue – related to the fact that you have to specify the choice values.

When you create a field via the User Interface, you get an error – SharePoint Choice fields require at least one choice.

image

As it turns out, my CHOICE field deployed via ELEMENTS.XML didn’t have any choice values.

Thus – when Microsoft Word was trying to display from this column (within the DIP), it was error’ing.

Simple answer was to make sure it included “at least one” CHOICE value – via the UI – or via my original feature :

<Field ID=”{a75f81c8-a860-4967-996a-0f7941b81119}” Name=”SenderLocation” Group=”SPR Columns” DisplayName=”Sender Location” Type=”Choice” FillInChoice=”TRUE” >
  <CHOICES>
    <CHOICE>OTHER</CHOICE>
  </CHOICES>
</Field>

So, if you have this error, make sure you include some values in the fieldef URL – it makes sense if you think about it. 

NB.  It will only error if/when the field is specified as “FillInChoice = true”

Happy SharePoint’ing !

Follow

Get every new post delivered to your Inbox.

Join 31 other followers