Happy Friday All!
So I made an adaptive carousel card on Teams that shows the address book from the 365. However it also shows the admin accounts. Currently, I got to hide the admin account using another card however I want to exclude those from the carousel all together:
I am struggling with the code. I know somewhere I need to have the IF statement here not the addressBookCard but I am stuck with the syntax:
[import](common.lg)
> Begin AddressBook
#addressBookCard(resultObj)
-IF: ${ contains(resultObj.mailNickname,'admin') }
- ```
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.2",
"body": [
{
"type": "Container",
"items": [
{
"type": "TextBlock",
"text": "Hidden Account",
"wrap": true,
"horizontalAlignment": "Center",
"weight": "Lighter",
"color": "Accent",
"isSubtle": true,
"height": "stretch"
}
],
"height": "stretch",
"minHeight": "230px",
"verticalContentAlignment": "Center"
}
]
}
```
- ELSE:
- ```
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.2",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"size": "Stretch",
"url": "https://redacted.sharepoint.com/_layouts/15/userphoto.aspx?size=S&username=${resultObj.Mail}",
"style": "Person",
"selectAction": {
"type": "Action.OpenUrl",
"url": "https://redacted.sharepoint.com/_layouts/15/userphoto.aspx?size=S&username=${resultObj.Mail}"
},
"width": "60px",
"height": "60px"
}
]
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "${resultObj.displayName} (${resultObj.mailNickname})",
"horizontalAlignment": "Right",
"isSubtle": true,
"wrap": true,
"size": "Large",
"fontType": "Default",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "${resultObj.jobTitle}",
"horizontalAlignment": "Right",
"spacing": "None",
"size": "Medium",
"color": "Accent",
"wrap": true
}
],
"height": "stretch"
}
]
},
{
"type": "ColumnSet",
"separator": true,
"spacing": "Medium",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "${resultObj.department}",
"horizontalAlignment": "Right",
"height": "stretch"
},
{
"type": "TextBlock",
"text": "${resultObj.City}",
"horizontalAlignment": "Right",
"spacing": "Small",
"height": "stretch"
},
{
"type": "TextBlock",
"text": "${resultObj.OfficeLocation}",
"horizontalAlignment": "Right",
"spacing": "Small",
"height": "stretch"
},
{
"type": "TextBlock",
"text": "${resultObj.Mail}",
"wrap": true,
"horizontalAlignment": "Right",
"spacing": "Small"
},
{
"type": "TextBlock",
"text": "${resultObj.BusinessPhones}",
"wrap": true,
"spacing": "Small",
"horizontalAlignment": "Right"
},
{
"type": "TextBlock",
"text": "${resultObj.mobilePhone}",
"horizontalAlignment": "Right",
"spacing": "Small",
"height": "stretch"
}
]
}
]
},
{
"type": "Container",
"separator": true,
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"wrap": true
}
]
}
],
"isVisible": false
}
]
}
]
}
```
# addressBook(resultArrObj)
[Activity
name = Global
Attachments = ${foreach (resultArrObj, x, json(addressBookCard(x))) }
AttachmentLayout = carousel
]
# SendActivity_k1Z42T()
- ${addressBook(dialog.resultArrObj)}
and here an redacted JSON that I am passing through to SendActivity:
[
{
"Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
"AccountEnabled":true,
"BusinessPhones":"1-555-555-5555",
"City":"Redacted",
"CompanyName":"Redacted",
"Department":"IT Dept",
"DisplayName":"Bob Smith",
"GivenName":"Bob",
"JobTitle":"Principal, IT Dept",
"Mail":"Bob.Smith@redacted.com",
"MailNickname":"bobsmith",
"mobilePhone":"1-555-555-5555",
"OfficeLocation":"01.01 Redacted",
"PostalCode":"55555",
"Surname":"Smith",
"TelephoneNumber":"1-555-555-5555",
"UserPrincipalName":"Bob.Smith@redacted.com"
},
{
"Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
"AccountEnabled":true,
"BusinessPhones":"",
"City":"Redacted",
"CompanyName":"Redacted",
"Department":"IT Dept",
"DisplayName":"Bob Smith (Admin O365)",
"GivenName":"Bob",
"JobTitle":"Principal",
"Mail":"bobsmithadmin@redacted.onmicrosoft.com",
"MailNickname":"bobsmithadmin",
"mobilePhone":"1-555-555-5555",
"OfficeLocation":"01.01 Redacted",
"PostalCode":"55555",
"Surname":"Smith",
"TelephoneNumber":"1-555-555-5555",
"UserPrincipalName":"bobsmithadmin@redacted.onmicrosoft.com"
},
{
"Id":"xxxxxxx-xxx-xxxx-xxxx-redacted",
"AccountEnabled":true,
"BusinessPhones":"1-555-555-5555",
"City":"Redacted",
"CompanyName":"Redacted",
"Department":"IT Dept",
"DisplayName":"Bob Smith",
"GivenName":"Bob",
"JobTitle":"Principal, IT Dept",
"Mail":"Bob.Smith@redacted.com",
"MailNickname":"bobsmith",
"mobilePhone":"1-555-555-5555",
"OfficeLocation":"01.02 Redacted",
"PostalCode":"55555",
"Surname":"Smith",
"TelephoneNumber":"1-555-555-5555",
"UserPrincipalName":"Bob.Smith@redacted.com"
}
]
Solved! Go to Solution.
Hi @nk1ng,
I still have to figure out how we can do this in code.
However, looking at your previous threads you are using a search for users action in Power Automate flow, correct?
If so, you could use this filter array action in the flow to exclude the admin accounts from your array.
Hi @nk1ng,
I still have to figure out how we can do this in code.
However, looking at your previous threads you are using a search for users action in Power Automate flow, correct?
If so, you could use this filter array action in the flow to exclude the admin accounts from your array.
Thank you so much, Expiscornvus! Works perfectly except when I try cast into a string, I get the original array?
Nevermind, just needed to grab from the body('Filter_array').
Thank you again!
-n
Keep up to date with current events and community announcements in the Power Virtual Agents community.
A great place where you can stay up to date with community calls and interact with the speakers.