Nintex Form - working with managed metadata fields

 

This is a post I wrote late last year, and applies to the Managed Metadata Fields in Nintex Forms via some "JavaScript middle-tier magic". 

 

Disclaimer

My conversations with the Nintex Form team back then was that at some point they might stop using the SharePoint Managed Metadata Fields and switch to their own control (similar to what they do with the people picker).  Then the following JavaScript code around Managed Metadata fields would stop working.

 

Goals

Nintex has a JavaScript wrapper API (NF.PeoplePickerAPI) around their People Picker Control.

Create something similar that allows me to wrap a Managed Metadata Field.

 

SPG.ManagedMetadataApi

 

(function (SPG, $, undefined) {

    var ctor = function (elem) {
        this.$elem = $(elem);

        var $taxonomyEditor = this.$elem.find(".ms-taxonomy");
        if ($taxonomyEditor.length) {
            this.controlObject = new Microsoft.SharePoint.Taxonomy.ControlObject($taxonomyEditor.get(0));
        }
    };

    ctor.prototype = {

        replaceTerm: function(label, termGuid) {
            var self = this;
            if (self.controlObject == undefined) return;

            var term = new Microsoft.SharePoint.Taxonomy.Term(label + "|" + termGuid);
            self.controlObject.replaceTerm(term);
        },

        clear: function() {
            var self = this;
            self.setRawText("");
        },

        setRawText: function (text) {
            var self = this;
            if (self.controlObject == undefined) return;

            self.controlObject.enableControl(true);
            self.controlObject.setRawText(text);
            self.controlObject.retrieveTerms();
            self.controlObject.validateAll();
        }
    };

    SPG.ManagedMetadataApi = ctor;
})(window.SPG = window.SPG || {}, NWF$);

 

Usage

 

  • List: My List
  • Field: MMField

 

/*
    using "normal" GET REST request doesn't bring back ManagedMetaDataFields, this is a workaround.
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/92cccd65-ba4c-4870-a858-7cd0e38a0482/how-can-i-use-caml-queries-with-the-rest-api
    because GetItems is a method on the List, this needs to be a POST operation.
*/

var url = _spPageContextInfo.webAbsoluteUrl +
    "/_api/Web/Lists/getByTitle('My List')/GetItems(query=@v1)" +
    "?@v1={'ViewXml':'<View><Query><Where><Eq><FieldRef Name=\"ID\"/><Value Type=\"Integer\">" + siteID +  
    "</Value></Eq></Where></Query></View>'}";

var promise = NWF$.ajax({
    type: "POST",
    url: url,
    headers: {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": NWF$("#__REQUESTDIGEST").val()
    },
    contentType: "application/json;odata=verbose",
    dataType: "json",
    cache: false,
    processData: true
});

promise.done(function (data) {

    var row = data.d.results[0];

    // similar syntax as NF.PeoplePickerApi
    var $mmField = new SPG.ManagedMetadataApi("#" + fieldMMField);
    $mmField.clear();
    if (row.MMField) {
        $mmField.replaceTerm(row.MMField.Label, row.MMField.TermGuid);
    }
});

taskeng.exe command prompt - get out of my face

 

So I was minding my own business working, and suddenly, a command prompt popped up, blocking my work for a few seconds and then disappeared. 

Very annoying.  Because now I'm distracted.  I need to hunt this thing down.

 

Figure: It can look like this.

 

A quick Bing search reveals that this is actually frequently reported, but most people have the wrong idea to go about fixing this.  They think "oh this is a virus, because I don't know what it was", so I'm going to run anti-virus and just blast away everything.

 

Here's what you should do.

 

Task Engine is Windows' Schedule Tasks.  It is running something.  That something can be a virus, but most likely, something you have installed.

  • So run Task Scheduler
  • Expand the "Task Status" area - this shows you tasks that has run in the selected time period.  You will see there are hundreds of tasks that has ran and will be running.
  • Change the time period filter to the smallest setting "Last hour"
  • Now pick off the single task just just ran.  Moments ago.

image

 

Bingo!

Dell SupportAssistAgent AutoUpdate

 

Task Schedule Library

 

  • Head to Task Schedule Library on the side menu
  • Find the task that's the culprit

 

image

 

Strangely, this app checks for update at 2:33PM every Thursday, right after lunch.  It's been annoying me for nearly a month.  I must have installed it on 13/02/2015.

Now, it's a fairly harmless app doing it update check.  Instead of just disabling the task, I can also:

  • Move the trigger to logon
  • Change the time to 1pm (lunch)
  • Or my favourite - wait for Idle

 

image

 

So, at Thursday 1PM, wait for up to an hour (so between 1pm to 2pm) for my computer to be idle for 15minutes.  Then you can run this app.  When I'm not watching.

 

Perfect

Working with XML in Nintex Workflows (simplified)

 

Problem:

You call an XML web service with Nintex Web Service or Web Request actions.  You get back a lot of XML, and it is very difficult to work with the namespaces getting in your way.

 

Solution:

 

1. Do a quick XSLT post processing in the action, remove all the namespaces with XSLT transform.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">    
<xsl:template match="*">        
    <xsl:element name="{local-name()}">            
    <xsl:apply-templates select="@* | node()" />        
    </xsl:element>
</xsl:template>    
<xsl:template match="@*">        
    <xsl:attribute name="{local-name()}">            
    <xsl:value-of select="." />        
    </xsl:attribute>    
</xsl:template>    
<xsl:template match="text() | comment() | processing-instruction()">
    <xsl:copy />    
</xsl:template>
</xsl:stylesheet>

 

2. Force top level XML node.

This ensures if your service returns multiple top level elements they get wrapped together.

 

3. Use XPath in Query XML Action like this:

/xml/Results/Result/Title

 

Sometimes, after you've wasted half a day working with XML, you just want the simple, no frills, just make it work version.

This will hopefully help you too.

 

Big thanks to Jumpei Yamauchi for helping me with this one.

Feb 2015 CU SP2013: Workflow CurrentSiteUrl is fixed

 

http://support.microsoft.com/KB/2920804

Assume that you create a SharePoint 2013 workflow by using SharePoint Designer 2013, and that the workflow contains an action that retrieves data from the "Current Site URL" field in the "Workflow Context" data source. When you run the workflow, the value retrieved from the "Current Site URL" field is missing a forward slash ("/") at the end of the URL.

 

A few months ago, Microsoft released an update to SharePoint 2013, and it broke many SharePoint Designer Workflows.

If you use the new capabilities in SharePoint 2013 to call REST services, it is very common to concatenate the URL using a combination of the Current Site Url as well as the api/ path.

"http://server/site/" + "_api/web/lists/getbytitle('Announcements')"

The problem is that Microsoft removed the trailing / in the Current Site Url.  This broke many REST calls.

"http://server/site" + "_api/web/lists/getbytitle('Announcements')"

Is no longer valid.  The fix is to reopen all your workflows that are showing this problem, and add a preceding / before _api.  Like this:

"http://server/site" + "/_api/web/lists/getbytitle('Announcements')"

 

Now, with the February 2015 patch, Microsoft is fixing the workflow action again.  Guess what.

"http://server/site/" + "/_api/web/lists/getbytitle('Announcements')"

 

I think this looks dirty

 

Technically, your workflow probably won't break over this.

"http://server/site//_api/web/lists/getbytitle('Announcements')"

Should return you the same values as

"http://server/site/_api/web/lists/getbytitle('Announcements')"

 

But it looks terrible.

SharePoint 2016 - debunking confusion and concerns

 

The announcement of SharePoint 2016 should not come as a surprise (Office 2016 was previously announced, and SharePoint has always been a product released in parallel).

http://blogs.office.com/2015/02/02/evolution-sharepoint/

What was the surprise, to me, is how many people immediately jump the gun and asks is there another version of SharePoint after 2016, I don't recall a time where when Microsoft announces Office 2010 is coming and people immediately ask is there an Office 2013.

 

Why the confusion

 

I think the confusion, or concern, is that customers can clearly see Microsoft's heavy investment in Office 365, and even the attitude of cannibalizing its own existing products to move forward. 

I think this is the right thing to do for Team Office.  Apple let iPhone ate the iPod.  Windows didn't evolve and got stagnant.

But our concern is genuine.  Many customers can not move to the cloud.  They are indeed worried whether they should continue spending in the on-premises product, or invest elsewhere.  It seems that Microsoft has not been investing in existing features, instead it has been investing only in Office 365 and very little is coming down the pike.

There are also much FUD spread by competitors implying Microsoft has abandoned on-premises and thus a customer should consider abandoning Microsoft and go with a competing on-premises product.

 

What we can safely assume

 

There are areas that Microsoft is playing to its strengths.  Many companies - Facebook for Work, Google Apps - are entirely cloud (or mobile) offerings.  SharePoint and Office 365 is a hybrid offering.  And in this strength, Microsoft is uniquely in the cloud, but also in your enterprise and cross-platform in your devices.  This isn't going to change, in fact, this is an area Microsoft will continue to expand the offering.

A decade ago, we can distil Microsoft and Windows down to A PC on Every Desktop

I'd like to think that for Team Office, it should be Office anywhere you do Work.

This means that perhaps while SharePoint the brand is fading into an on-premises only product, SharePoint the product is never going away.  It has not been given the 10-year support life line.  And Microsoft continues to invest in the product.

 

What could the next version of SharePoint look like?

 

I see two possibilities with the shape of the next version of SharePoint. 

It could be a stand alone product, in the shape of SharePoint 2019, launched with Office 2019 desktop suite.

It is also possible that in the SharePoint 2016 timeframe, the product becomes Evergreen and future updates are rolled out in the form of Service Packs.

 

I would kiss the Microsoft Product Manager that makes SharePoint On-Premises Evergreen.  This isn't something unimaginable.  Office 365 has already gone that route.  Windows 10 is envisioned as Windows as a Service and new updates will just roll out new features.  An Evergreen SharePoint effectively means this would be the last release version of SharePoint - and that is great for customers.

It's worthwhile to note that this isn't a decision Team Office has to make in the 2015-2016 timeframe.  This is a decision that should be made in the 2016-2018 timeframe.  By that time, Microsoft and customers would be well-understood about what Microsoft means when it says Windows As A Service.

 

So no rush.  But you know what I want, Dear Team-Office-Santa.

 

What I want to see more

 

http://blogs.microsoft.com/firehose/2015/02/02/how-sharepoint-will-evolve-in-the-cloud-with-office-365/

Reading between the lines in the Office announcement, I think Office 365/SharePoint announcements coming up in Ignite will be split into really three areas:

  • Office 365 / Cloud / SaaS - new features will appear here first.  That's what Cloud-First means.
  • SharePoint 2016 - boring backend updates, applicable learnings from Office 365 (probably not much - since we aren't big on hosting multi-tenanted environments in a single enterprise).  Database stuff.  High availability.  API updates and APPs that runs in the cloud but also on premises.
  • Hybrid, Hybrid, Hybrid - how to connect everything from Office 365 with On-premises SharePoint: Sway.  Video Portals.  The mystical "Next Generation Portals", Yammer, Groups, Delve and Hybrid Search. 

 

I expect news to be a bit light between now and Ignite conference, where Microsoft is storing up bags of product announcement goodies.

http://ignite.microsoft.com/

 

I'm preparing for everything to get more awesome.  And I don't think SharePoint is going away anytime soon.  If anything, it is still right in the middle of everything (if you are on the ground, not just in the cloud).

 

I'm Loving every bit of it.  Turn it up to v15!