Last active
November 6, 2018 20:18
-
-
Save trisharia/cbd01e09c56eccc5886af36612b12536 to your computer and use it in GitHub Desktop.
Get the value from vCACCAFELiteralMap
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
// VMware vRealize Orchestrator action sample | |
// | |
// Returns the value of a given key defined in a vCACCAFE:vCACCAFELiteralMap | |
// Performs depth-first search | |
// | |
// For vRA 7.0+/vRO 7.0+ | |
// | |
// Action Inputs: | |
// map - Any - the vCACCAFE:vCACCAFELiteralMap to parse | |
// key - string - Key for searching in the literal map | |
// | |
// Return type: Any - the value for the given key | |
return getValueFromDataMap(map, key); | |
function getValueFromDataMap(map, key) { | |
var mapKeys = map.keySet(); | |
var data; | |
for each (var mapKey in mapKeys) { | |
//System.debug("key: " + mapKey); | |
data = map.get(mapKey); | |
if (mapKey === key) { | |
System.log(mapKey + ": " + data); | |
return (data) ? data.value : null; | |
} | |
if (data) { | |
if (System.getObjectType(data.value) === null) { | |
try { | |
data = getValueFromRequestDataMap(data.value, key); | |
if (data) return data; | |
} catch(e) { | |
System.error(e); | |
} | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Trisha,
Thanks for the provided code, however I'm getting the following error: ReferenceError: "getValueFromRequestDataMap" is not defined.
Any ideas how to fix it ?
Thanks