Formatting Slack Messages from Dynamics365

In creating my messaging application that sent data from Dynamics365 to SLACK, I wanted to get a little fancier and not only send static content but actually embed the link to the actual record with some content to provide context to the user.

I also wanted to do a bit of formatting (bolding and links) which is relatively easy but does not follow HTML notation.  The formatting reference for SLACK is located here.

For my scenario (displaying messages for Leads), I wanted to bold the entity (because this will be used by other ones at some point) and open directly to the record when clicked.

The url format to accomplish this is as follows;

A new *Lead* has been created – <{0}/main.aspx?etc=4&id={1}&pagetype=entityrecord|{2}>

Where the first parameter is my Dynamics tenant, the “etc” value is the enum reference for the lead entity and the id, is the guid that I captured in the plugin.  If you do not include the pagetype=entityrecord value, your page will open to the default dynamics dashboard.

If you are stuck trying to get this information, simply click the arrow “popout” button from the top right of your screen.

Within the plugin, I then highlighted a field (in this case subject) that I chose to get from the newly created record that would be placed in place of the link via this notation.

entity.GetAttributeValue<string>(“subject”).ToString()

And once done, I was able to have something cool like the following displayed.

slack2

Where the word “Lead” is in bold and the user can click on any of the highlighted text to access that record.

Post A Reply

%d bloggers like this: