Flic Buttons and Rest

So ordered this hub and some buttons to try to do some simple “push this button to do this” integrations.

They have an app to run a web request. I don’t have the hardware yet, but it looks like you can make the tasks on the app with your phone and just trigger it from my phone.

I was able to use the API/help for rest connected to our 10.2 test system from a browser. I added a row to UD09 using the “try it” button from swagger. Cool! Now I want to be able to do the same thing with the Flic App. In the UI there is a selection for get, post, put and delete. I’m using post. The next line is for URL, and I can grab that from the Swagger help.

The next line is where I get stumped. There is a line for header. I’m assuming that’s going to be some Epicor login information right? I’ve been looking through some stuff trying to understand what I need to do, and I think I’m getting there but I need a little guidance. I’ve been reading these posts and I’m understanding more and more, but not quite to the point of being able to implement it yet.

https://sendgrid.com/blog/magic-behind-basic-http-authentication/

After that, it’s the body, and I grabbed that from the swagger help, so I think that I am good there.

We also will be working through LetsEncrypt to get a real certificate, I’m sure that will help.

I don’t see their docs and how to write the app but a few things…

  • You need to ‘login’ to ERP somehow e.g. pass credentials to authenticate the ‘button’. You COULD just hardcode a ‘ButtonAgent’ user in E10 for a POC but hopefully we can progress beyond that for production level. In that case, create a test user and brag the ‘basic auth’ line for it from PostMan for your test user. Try something simple like adding a Tip record from Postman to see how things get updated. Bonus points for adding a BPM to write out the tip number and the userid to a UD table or append to the tip text to play around and learn what is happening.

*Set Context - Which company / plant / other Session variable do you want to have the server call execute under? You can easily pass the company in the header. You probably will be hard coding that for this in production since it will be hard to change companies on a button press :wink: (Press once for Company 1, press twice for company b? Probably not).
NOTE: Company setting is an interesting (frustrating) topic for many. There are tools where you cannot pass custom headers such as the Epicor CallSettings header where you set the company. This means you may need a different identity per company. Not applicable to your button POC but something folks using tools like Microsoft Flow have to struggle thru. With no header for Company, the users ‘CurComp’ (last logged in company) is used to set context. That means some folks have had to add a different user for each company. Unfortunate but a valid work around.

I’ll be interested to see what you come up with!

Well it’s not really writing an app (that’s way above my skill level). It’s using their app to make a internet request. What I am hoping to do is configure a task for each button to make a row in a UD table so I can do something with it in E-10. The use case is, the shop has a bucket of safety labels, when the bucket gets low, they can push this button to signal the purchaser to order more, or even maybe down the road bypass the purchaser altogether and just order them from the supplier. Basically copying amazon. :wink:

Maybe it’s not possible to set up what I want in a UI type environment. I know that I don’t know enough about security, but I am trying to learn.

I might use some other tools like zapier, to do something independent of epicor, but I really like the tools that I have in BPM conditions to be able to filter out things like the same button getting pressed every 10 minutes for 2 days. I want the shop floor to not be afraid to push the button when they need it, so I have to find a way to filter out false positives, which I could do with a BPM. Maybe Jitterbit will be a good option in the future?

Here’s a screen shot of the input screen. I’m not understanding the terminology of the header key and string, so I’m not sure how to translate the example that is in help.

(click on the picture to expand it, it’s taller than it shows in the preview)

So your Authorization header should look like
Authorization: Basic ZXBpY29yOmVwaWNvcg==

where the crazy looking text is a base64encoding of your epicor username and password
Authorization: Basic base64(manager:manager)

Not sure how you can set that in your button but you may be able to just hard code it.

use this to encode, just type in user:password and get the crap out and put it in the Authorization header

so here’s a dumb question, there are a bunch of headers listed in help besides the authorization header. They are titled custom headers. Do I need to define some of those too? (Or all?)

You could… but you don’t need to.

Some of those could be the CallSettings (Company, Plant etc)

Alright, I got this working. These last 3 lines were done with the flic app from my phone. Interestingly enough, it doesn’t look like the request has to go out to any cloud server because if I turn off the WIFI on my phone , it won’t complete the request, so it seems like it’s only internal. Which for this application is good. (the one that has no-wifi in key 3 is me sending it after I reconnected to wifi.)

1 Like

Now that I got that working, I will need to inject some logic for filtering somewhere. What’s the best way to do this? And what’s the easiest? (Because I’m sure they are not the same)

Here’s my use case:

The shop floor runs out of labels all of the time because no one will take the time to tell the purchaser that we are almost out. I want to put a button the bin with the labels that someone can push when they are almost out. That will write a row to a UD table in E-10 where I can do stuff with it. (like display on a dashboard, or even get to the point where there is a standing PO and automatically orders the stuff)

Obviously, I don’t want 50 orders a day of these labels if they are out and everyone pushes the button. Also I don’t want to scare people from pushing the button thinking that they are going to order too many. I want to tell them “if it’s almost out, or out, just push the button. I’ll handle it from there”. So I need some sort of

My first thought is to put a time stamp into the rest call. Considering that I can’t code, I am limited to what I’m given the in flic API. I don’t think that there is a way for me to put constants like the current time this API. (That’s probably a good thing anyways since time stamps are always an argument waiting to happen, which time zone, what format, etc…)

The next thought, and the one that I think will work the best is to use a data directive BPM to do all of the heavy lifting and simply send the key with the part number in it, and then to set one of the keys to the current day via BPM. That way I can only write one row written a day, which for this application is good, and then I can filter out the repeat days by the lead time in the system using a dashboard or send an e-mail via BPM or something.

Thoughts? Ideas? I’m just brainstorming some things and am open to other ideas.

I think the easiest thing is going to be to set the Primary Key (key1) in your UD record to be the “data” or part that the button pushes. Epicor will automatically not allow any more entries to be made as long as that one exists.
Then when you fulfil the requirement, clear the record. (If I’m understanding you correctly)

That’s an option. I kind of like the idea of having a transaction history though. (although I suppose that would show up the part tran history… hmmm. Something to think about.), and an automatic clear based on lead time. I would love it if I could rely on receipts and clear based on when they are received… Probably not though. (It’s hard to program around human error.)

Maybe I should do something with a clear row on receipt combined with a notification (e-mail, or something) that something is overdue to be received.

So I have another question about REST and BPM’s. I know that I can use data directive, because that doesn’t care what makes the change.

For using Method directive, It looks like it’s harder to get a trace (you need to be on the server and it’s not a nice GUI like the client trace is). And, does it use the same BO in such a way that you can use method directive?

Well, I answered my own question. The post uses UpdateExt, and I can make BPM’s that work with that. (I made myself a counter with my button using a pre-process BPM on UD09UpdateEXT.)

Server trace is settable from the client trace as well:

1 Like

I’m having a hard time getting this to work. (I probably don’t know what I am looking at. )

The rest implementation doc has this.

So I tried what you had in your screen shot and trace://ice/fw/restapi and neither of them return anything is the log file when I click on view. (the local one). If I turn this on, do I still have to go the server to see it?

Ok, now I can’t figure out why I can’t use a condition in a BPM.

If I run my BPM with no conditions, it works. (my counter) . But when I put a condition in there, it won’t work You can see it can’t do anything but go through the rest of the steps after the condition (because both true and false go to the next step), and the condition should come back true anyways because I have all of the possible rows set up with an or clause. Can anyone tell me what I could be doing wrong where the condition would stop the BPM from working?

Even if I clear out the condition altogether (which the validation says should go through the true side) it doesn’t want to work.

oh, if you are trying to pass the restapi over the wcf calls, you are not going to get anything - no REST involved (and you don’t need it for this).

You are trying to figure out what methods and queries and bpms, etc are being invoked by server logic? That’s nothing in the restAPI trace. The RestAPI trace is about the wire to BO transition. What happens behind the scenes in the biz logic doesn’t matter to whatever wire protocol is throwing bits back and forth between the client and server.

Except when I am trying to set up a BPM to do smarter things besides “make a new row with these static hardcoded values”. I’m working with a button. The only input is “click”, then I can send some hard coded values. Everything else has to be coded somewhere else to make that click useful. So I want to filter some things out, do things like add to an existing value, etc. I need the BPM to do that because the API I am using can’t call the get rows and use that information to form my post. So a trace with regards to REST on what BO’s are called could be useful to me so I don’t have to guess where I have to put my BPM’s.

That being said, there are only 3 to pick from (GetRows, GetList, and UpdateExt) so it’s not too hard to guess, and a UBAQ is probably a better way to go because I can control everything with the BPM on the UBAQ and not worry about affecting anything else that doesn’t call the UBAQ. That’s going to be my next stop on this self education journey to learn this stuff!

But still, a trace with the applicable BO’s would be helpful…

We are missing each other in intent - (I blame me as I have been on Vaca).

My point was that you can still trace BO activity even without server access.

Update:

I finally got the flic buttons and the hub today. First test, send a slack message, that’s easy.

Second test, send a rest message to write a row on a UD table. It works!

So I can push a little black button, and it writes a row. Now I just have to figure out what I want to do with it, and what I can make happen with BPM’s

1 Like