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:
Attachment-> (bob's card #1), (hidden admin bob's card #2), (bob's card #3) with the if statement on addressBookCard
Need to have:
Attachment-> (bob's card #1), (bob's card #3) with the if statement in addressBook in theory anyways, if that makes sense?
Here is the whole bot responses code to understand what I am saying:
[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"
}
]