web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Bot Framework // Exclu...
Copilot Studio
Answered

Bot Framework // Excluding part of JSON?

(0) ShareShare
ReportReport
Posted on by 71

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:   

nk1ng_7-1631289222965.png

nk1ng_3-1631285755039.png

 

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:

   # addressBook(resultArrObj)
   [Activity
     name = Global
     Attachments = ${foreach (resultArrObj, x, json(addressBookCard(x))) }
     AttachmentLayout = carousel
   ]
 
Currently:
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"
 }
]

 

 

Let me know and if you can help!
Categories:
I have the same question (0)
  • nk1ng Profile Picture
    71 on at

    Nevermind, just needed to grab from the body('Filter_array').

    nk1ng_1-1631541438720.png

     

    Thank you again!

    -n

  • nk1ng Profile Picture
    71 on at

    Thank you so much, Expiscornvus!  Works perfectly except when I try cast into a string, I get the original array?

    nk1ng_0-1631541086866.png

     

     

  • Verified answer
    Expiscornovus Profile Picture
    33,417 Most Valuable Professional on at

    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.

     

    nicknamedoesnotendwithadmin.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 414

#2
chiaraalina Profile Picture

chiaraalina 130

#3
S-Venkadesh Profile Picture

S-Venkadesh 84 Moderator

Last 30 days Overall leaderboard