CRM 2011 – UnRecognized ‘Edm.Guid’ literal ‘guid’null’

A user had reported this error and the Hosk was tasked to investigate


UnRecognized ‘Edm.Guid’ literal ‘guid’null

EDM.guid error


What made investigating this error more tricky, was it occured only when a new record was created.

I couldn’t seem to catch a debug message on the form onload because I think it creates new javascript files, so if you do put a breakpoint on a file it’s not used.

I did some investigation using the internet about this error

This blog had a similar error before to do with dates and json queries


I found this page on json fields

Edm.Guid Literal form of Edm.Guid as used in URIs formatted as a JSON string


I think the problem was definitely related to an Odata query and the code I was looking at used the Rest framework.


Fiddler to the rescue

I turned on my trusty Fiddler to try and capture what was happening.  I ran the create form, got the popup error and then in Fiddler logs I could see last line had a nasty red triangle with an exclamation in it.

I found the Odata query and could see it the filter in the oData statement was null, which meant it was trying to retrieve some a single record but was passing a null guid.


I searched the F12 debugger using the select statement to find where the code was.

The code was actually being triggered from by a ribbon button and the evaluate javascript.


Debugging a ribbon

Debugging a ribbon can be a little bit tricky because you can’t use the F12 debugging method and you have to put in a


when the browser hits this, it will ask you  if you want to debug the code in Visual Studio, you say yes please.

You will now be able to step through the code to find out the problem.

Here is the code (changed to make it generic)


if (selectedId == null)
selectedId =;

if (typeof selectedId == "object" && selectedId != null)
selectedId = selectedId [0]. id;

var fieldResults= NttDataUk.Functions.Rest.retrieveMultipleSync("contactSet",
"first name,last name,statuscode",
"contactId eq guid'" + selectedId + "'");
if (fieldResults== null) {
return false;


So the problem was it was getting the guid of the record but new products don’t have guids because the guid is only created when the new record is saved.

The actual error was being generated by the Odata query which tried to get a record using a guid = null.


There are two solutions to this problem.

Change the display rule for the ribbon button to only display for records in a form state which doesn’t equal create

display rule ribbon

The other solution was I could add in check in the Javascript, to add a check to see if selectedId == null then return false, this would show but not enable the button.

The advantages of not displaying the button would also save a little bit of time drawing the button.  You should consider I changed the display rule and not the enable rule because I felt there wasn’t any point in showing a button you can’t use.


5 thoughts on “CRM 2011 – UnRecognized ‘Edm.Guid’ literal ‘guid’null’

  1. Toni Serrano April 23, 2015 / 4:46 pm

    What tool use for change ribbon please?


  2. Peter Taylor May 4, 2016 / 7:52 pm

    To find the culprit you could also go to the F12 tools in FireFox. When the error gets thrown it’ll show you which script is firing it, then you go and set a breakpoint on it, refresh the page, and you have the full call stack. In my case it was a form script.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s