Skip to content

Instantly share code, notes, and snippets.

@temmyraharjo
Created August 9, 2018 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save temmyraharjo/d769a2f3335501875466ca22d3f4d4fb to your computer and use it in GitHub Desktop.
Save temmyraharjo/d769a2f3335501875466ca22d3f4d4fb to your computer and use it in GitHub Desktop.
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