Custom Page – Teams Integration

Did you think my last post was the final stage of the “Custom Page – Win Notification“? Of course not!! We have one more important step to complete the whole solution.

I am all about salespeople being able to boast about their sales. If you meet a salesperson who doesn’t love to brag about closing, are they even in sales? 😉

Communication is key when you work in organizations of any size and location Onprem/Online/Hybrid. Doesn’t matter where you work, we can all agree that spreading the word around, and making sure everyone gets the latest news is hard. Microsoft is making it pretty obvious that Teams is a preferred channel, so that’s where I also wanted to focus my energy.

Notify the team

I decided to extend the solution a bit to reuse the GIF that we got from the last closing screen, and include it in the Teams integration that I wrote about earlier in the Adaptive Cards.

The first thing I did was to add a new group of fields for the Teams notification. I wanted to let the user choose if they wanted to post the sales to Teams or not. The obvious reason is that some opportunities might have to be reopened, and you don’t want the credit 2 times etc. It’s just a simple logo, text and boolean field.

The next step is adding the variable BoolPostTeams to the run statement of the Power Automate when I click “Confirm Win”.

On the Flow side of things, I will now receive 1 more variable that I can handle. Because I wanted to use the bool type, I have to convert the string “true/false” to a boolean

bool(triggerBody()['Initializevariable2_Value']) 

What team are we updating?

Glad you asked 😉 A part of the solution is to include a Team ID and Channel ID. I added these fields to the Business Unit Table. When we store the Teams/Channel ID’s at this level, we can reuse the same solution for several teams in an organization without having to hard code anything.

These are simple text fields that will hold the unique values to the Team and the Channel you want to notify.

NB! A tip for getting the Teams ID and the Channel ID:
Add the Team and Channel via the drop-down selector (flow step below). Then open the “peek code” to see what the ID’s of the teams are. If you don’t understand this step, just have a look at my video in the final post of the series 🎥

Back to the flow!

We update the get Opportunity with extra linked tables. This way we don’t have to do multiple retrieves, and only get the fields we need from the linked tables.

parentaccountid($select=name), owninguser($select=fullname, internalemailaddress), owningbusinessunit($select=saleswin_teamschannelid,saleswin_teamsid)

After we update the opportunity as closed with our Custom Action “close opportunity”, we check if the close dialog wanted to notify the team.

Then we need to get the @mention tag for the given user that made the sales. Here I am using the email address from the SystemUser table we are getting from the Opportunity extended table.

Finally, we post the Adaptive Card to Teams and behold the wonder of the adaptive card!! 💘

{
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "1.2",
    "body": [
        {
            "speak": "Sales Morale Boost",
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": 8,
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "🚨WIN ALERT🚨",
                            "weight": "Bolder",
                            "size": "ExtraLarge",
                            "spacing": "None",
                            "wrap": true,
                            "horizontalAlignment": "Center",
                            "color": "Attention",
                            "fontType": "Default"
                        },
                        {
                            "type": "TextBlock",
                            "text": "@{outputs('GetOpptyInfomation')?['body/name']}",
                            "wrap": true,
                            "size": "Large",
                            "weight": "Bolder",
                            "horizontalAlignment": "Center"
                        },
                        {
                            "type": "ColumnSet",
                            "columns": [
                                {
                                    "type": "Column",
                                    "width": 25,
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "text": "🏠 Kunde",
                                            "wrap": true,
                                            "size": "Large",
                                            "weight": "Bolder",
                                            "horizontalAlignment": "Right"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "text": "💲 Verdi",
                                            "wrap": true,
                                            "size": "Large",
                                            "weight": "Bolder",
                                            "horizontalAlignment": "Right"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "text": "👩‍🦲 Selger",
                                            "wrap": true,
                                            "size": "Large",
                                            "weight": "Bolder",
                                            "horizontalAlignment": "Right"
                                        }
                                    ]
                                },
                                {
                                    "type": "Column",
                                    "width": 50,
                                    "items": [
                                        {
                                            "type": "TextBlock",
                                            "text": "@{outputs('GetOpptyInfomation')?['body/parentaccountid/name']}",
                                            "size": "Large",
                                            "weight": "Bolder"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "text": "@{outputs('GetOpptyInfomation')?['body/actualvalue']}",
                                            "weight": "Bolder",
                                            "size": "Large"
                                        },
                                        {
                                            "type": "TextBlock",
                                            "text": "@{outputs('Get_an_@mention_token_for_a_user')?['body/atMention']}",
                                            "weight": "Bolder",
                                            "size": "Large"
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        {
            "type": "Image",
            "url": "@{body('Parse_JSON')?['data']?['images']?['original']?['url']}",
            "horizontalAlignment": "Center"
        }
    ]
}

Now, this is what an opportunity close dialog should look like!! 🙏🏆🌟🎉


Discover more from CRM Keeper

Subscribe to get the latest posts to your email.

Leave a comment