Thursday, 15 December 2016

Acumatica and Microsoft Flow

Hi Everyone,

Recently Microsoft has added a new tool to their Office 365- Microsoft Flow
With help of my college - Tim Rodman, we have done some investigations on how it can be used with Acumatica.

I think that in modern internet of services and things services like Microsoft Flow, Azuqua and Zappier might be very useful.

Microsoft flow is most modern here so it does not looks like very mature and stable now. But i belive it is quite promising as Microsoft has enough resources to integrate it with most of Office 365 services. Looking forward to see that progress.

However even now it has some nice things, like HTTP integration where you can call various of web services using REST API.

And really luckily Acumatica already supports REST API.
I have played around it and have tested 3 scenarios:

  • Authentication
  • Creation of Acumatica entity from Flow objects. In my case i got just a simple email, but in more complex scenarios it can be separate system.
  • Retrieving object from Acumatica. Another simple thing that just emails me some data from Acumatica, but that be just a part of the flow and can be accepted by 3rd party system differently.

Lets go though these 3 processes.

Authentication
If to be honest thought that it would be hardest part, as Acumatica uses Cookies and it should be provided with all requests.
In reality it was much simpler than I suspect. Flow has ability to pass-throw headers from previous step to the next one. That is exactly what we need to maintain authentication.

Authentication is done absolutely the same way like it described in previous article. Passing login and password with JSON object.

{
    "name" : "admin",
    "password" : "123",
    "company" :  "Demo"
}

The output of that step will go to the headers input to the next step.

Creation of item
Ok, now lets check real scenario - when email is send to special folder we can create a customer in Acumatica.
So our flow will consist of 3 steps: Email, Authentication, Creation of Customer

I suggest you to test creation of customer in Postman (like described in previous article) first, than copy it to the Flow. Caution: there are some bugs right now with designer. Sometimes it shows JSON object is not valid even if it is valid.

When you have tested it, create a new HTTP flow step and

  • Add headers from authentication step to the new one
  • Set URL as it required for Rest API (http://acumatica.com/entity/Default/6.00.001/Customer)
  • Add step body with JSON object. Note that you can include output form previous steps (like email) as a part of your new JSON object.

{
 "CustomerID" : {value : "NewOne" } ,
 "CustomerName" : {value : "[SUBJECT]" },
}

Now you can save your flow and test it. When you add a new email to configured folder:
 it will trigger the flow
and Create/update Acumatica entity.


Retrieving of Data
The same way you can retrieve data back. Create a flow that will check Acumatica once in a while and retrieve list of stock items. Create following steps

  • Authentication
  • Retrieving of record
  • Send email with result


When you execute this flow you will have an email with JSON data in your mailbox.
If you are computer or web service, it is valuable for you :)

Have a nice integration!

1 comment:

Carlos said...

Very interesting how all technologies can work together.. i'll be following this kind of post.! Great Job.