Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 17314

Send tweets from AX via the Retail module

$
0
0
Once again I fell over some objects with interesting names in the retail code. This time I learned that you can update Twitter and Facebook from AX.

In the following I'll describe the Twitter setup.

First of all, you need to setup an application under your Twitter account. Go to https://apps.twitter.com/ to do that. Under settings, you need to fill in:
  • Name: This will be the name of your application. Mine is called PalleAgermarkTest.
  • Description: This shows when for example you later on link the application to be able to use your Twitter account.
  • Website: This should a website where users can download the application. Since I don't have a real application, I have just put the address of my blog.
  • Callback URL: This is needed when AX links the application to your Twitter account. Again, the address is not important (but an address is needed) for this demonstration and I have again put the address of my blog here.
On the API tab of the setup, you'll get an API key and an API secret. You will need these in AX.


On the Permissions tab, give the application write access to the Twitter accounts that sign up to the application:

That's it for Twitter.

Go to Retail \ Setup \ Parameters \ Retail parameters to setup some seed data for the retail module. Click the Initialize button:



Now in AX, go to Retail \ Setup \ Parameters \ Retail shared parameters and enter the API key secrets from above:


Then go to Sales and marketing \ Setup \ Campaigns \ Media types and add Twitter as a media type:


Now when clicking the Link account button, you should get the option to link your Twitter account (the screen clip is in Danish, but you should be able to get the idea):


So now all the bits and pieces are setup, and a very simplified piece of code like this example is able to post to Twitter:

static void Tweet(Args _args)
{
smmCampaignMediaTypeGroup mediaTypeGroup;
RetailMediaChannelConnectorSettings settings;
RetailMediaChannelTwitterConnector connector;
RetailMediaChannelMessage message;

select firstOnly TableId from mediaTypeGroup
where mediaTypeGroup.CampaignMediaTypeDescription == 'Twitter'
join settings
where settings.smmCampaignMediaTypeGroup == mediaTypeGroup.CampaignMediaTypeId;

connector = RetailMediaChannelTwitterConnector::construct(settings);
message = RetailMediaChannelMessage::construct();
message.parmMessage("Tweet from AX");
connector.push(message);
}

The result:



Viewing all articles
Browse latest Browse all 17314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>