Hey @ts_fpatterson,
This is great! Just wanted to share another way of doing this same thing that may be a bit more effective in some situations.
If you have an Entra ID source that pulls in assignedLicenses
as an attribute, you can crawl that to check the license(s) actually assigned to an account. By checking directly against Entra ID, you’re ensuring that your data is catching all licenses applied to all accounts, regardless of whether it was set via AD or some other way, or if someone messed with the group mappings without you knowing.
In this transform, we are checking for specific String ID
values that map to Entra license types; you can find the mapping here to select which license types actually apply to your environment, and just update/add to the list in the transform. Note that if you change any of the variable names or add new ones, you’ll also need to update the array in the value
at the bottom! In this example, we’re looking for whether a user has an E1, an E5, and/or an F1 license (they can have more than one!!).
{
"name": "licenseCheck",
"type": "static",
"attributes": {
"e5": {
"attributes": {
"values": [
{
"type": "accountAttribute",
"attributes": {
"attributeName": "assignedLicenses",
"sourceName": "Entra ID",
"accountPropertyFilter": "(assignedLicenses.contains(\"ENTERPRISEPREMIUM\"))"
}
},
"false"
]
},
"type": "firstValid"
},
"e1": {
"attributes": {
"values": [
{
"type": "accountAttribute",
"attributes": {
"attributeName": "assignedLicenses",
"sourceName": "Entra ID",
"accountPropertyFilter": "(assignedLicenses.contains(\"STANDARDPACK\"))"
}
},
"false"
]
},
"type": "firstValid"
},
"f1": {
"attributes": {
"values": [
{
"type": "accountAttribute",
"attributes": {
"attributeName": "assignedLicenses",
"sourceName": "Entra ID",
"accountPropertyFilter": "(assignedLicenses.contains(\"M365_F1_COMM\"))"
}
},
"false"
]
},
"type": "firstValid"
},
"value": "#set($out = '')#foreach($item in [$e1,$e5,$f1])#if($item != 'false')#if($out.length() > 0)#set($out = $out + ',')#end#set($out = $out + $item)#end#end $out"
}
}
Since we can’t gracefully join an array, we have to manually combine the items, and we only want to drop in a delimiter where necessary. The Velocity in the value
breaks down like so:
#set ($out = '') ##Instantiate a string variable
# foreach ($item in [$e1,$e5,$f1]) ##Create and populate array
#if ($item != 'false') ##Check the current item
#if ($out.length() > 0) ##Check if there's already a value
#set ($out = $out + ',') ##If so, add a comma delimiter
#end ##Close the inner if statement
#set ($out = $out + $item) ##Add value to string
#end ##Close outer if
#end ##Close foreach loop
$out ##Output the string