C#, CRM

Connecting to Dynamics 365 with TLS 1.2

Another fix for connecting to CRM 365.

I had a CRM ConnectionString that had previously been working but after an update to Dynamics 365 no longer worked. There didn’t seem to be any exception and the LastCrmError property didn’t contain anything helpful.

Continue reading

Advertisements
C#, CRM

CRM Plugins – Input Parameters and Early Binding

I recently came across this problem looking at a CRM instance that had been upgraded to use early-binding. They had done something like below:

var accountInputParameters = ((Entity)context.InputParameters["Target"]).ToEntity<Account>();

This takes the InputParameters (which is of type Entity) and then bound it to the Account early-bound type.

While this seems like a good idea on the surface, as it allows all the fields of the Account to be accessed using strongly typed properties, the customer reported some strange behaviour on their Accounts.

Continue reading

CRM, JavaScript

Some helpful CRM 2016 Bookmarklets

I’ve been working in CRM Online (2016) a little for the past few weeks and I found these little bookmarklets to be helpful.

For those that don’t know, a bookmarklet is a snippet of JavaScript that can be saved as a Bookmark in Chrome, IE or Firefox. By prefixing your JavaScript function with javascript: you’re telling the browser to execute JavaScript rather than go to a particular URL

So far I have bookmarklets to

  • Print the current entity’s schema name
  • Print the current entity’s ID
  • Reopen the current entity’s form

The Print ones are quite nice because I used CRM’s in-built notification system.

Continue reading

JavaScript, SharePoint, Web Services

Using SharePoint REST to create a folder

I was tasked with creating some folders in a Picture Library and I thought that this would be the perfect opportunity to use the SharePoint 2013 REST API for the first time.
It was actually quite easy:

function CreateFolder (){
    var url_web;
    var pictureLibrary
    var folder_name;
    var folder_path;

    url_web = _spPageContextInfo.webAbsoluteUrl;
    pictureLibrary = 'Pictures';
    folder_name = 'jasonscript';
    folder_path = pictureLibrary + '/' + folder_name;

    jQuery.ajax({
        'url' : url_web + "/_api/Web/Folders/Add('"+ folder_path + "')",
        'type' : 'POST',
        'headers' : { 
            'accept' : 'application/json; odata=verbose', 
            'content-type' : 'application/json; odata=verbose',
            'X-RequestDigest' : $('#__REQUESTDIGEST').val()
        },
        'success' : function (evt){
            // folder has been created
        },
        'error' : function (jqXHR, textStatus, errorThrown){
            // handle the error
        } 
    }); 
 }

The biggest problem that I had was that I found that the Add method seems to only accept values wrapped in single quotes.
I typically use single quotes to define my strings

    var myString = 'wrapped in single quotes';

However, when I tried this

    url_web + '/_api/Web/Folders/Add("'+ folder_path + '")'

I kept getting ‘bad request’ errors. Switching the quotes around resolved this problem.

    url_web + "/_api/Web/Folders/Add('"+ folder_path + "')"

Weird