Monday 2 November 2015

How to check GUIDs are equal in JavaScript

Hi,

In CRM, at times we get requirement to check two GUID's are equal or not.

Here is the JavaScript code to check two GUID's are equal.

function GuidsAreEqual(guid1, guid2) {
    var isEqual = false;
    if (guid1 == null || guid2 == null) {
       isEqual = false;
    }
    else {
        isEqual = (guid1.replace(/[{}]/g, "").toLowerCase() == guid2.replace(/[{}]/g, "").toLowerCase());
    }
    return isEqual;
}
Hope this helps.

--
Happy CRM'ing

Gopinath

No comments:

Post a Comment