Created
August 9, 2018 03:40
-
-
Save temmyraharjo/d769a2f3335501875466ca22d3f4d4fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getIdentityById (identityId) { | |
var key = 'identity' + identityId; | |
var fnSearch = function () { | |
var fetchXml = '<?xml version="1.0"?>' + | |
'<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">' + | |
'<entity name="new_identity">' + | |
'<attribute name="new_identityid"/>' + | |
'<attribute name="new_name"/>' + | |
'<attribute name="new_profile" />' + | |
'<attribute name="new_membership" />' + | |
'<filter type="and">' + | |
'<condition attribute="new_identityid" operator="eq" value="' + identityId + '" />' + | |
'</filter>' + | |
'</entity>' + | |
'</fetch>'; | |
new_XrmSvcToolkit.fetch({ | |
fetchXml: fetchXml, | |
async: false, | |
successCallback: function (retrieved) { | |
cache[key] = retrieved.entities.length > 0 ? retrieved.entities[0] : null; | |
}, | |
errorCallback: function (error) { | |
throw error; | |
} | |
}); | |
}; | |
return function () { | |
return getOrSetCache(key, fnSearch); | |
}(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment