DEMO: the CRM app EXPOSING object via REST. Easy!

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

DEMO: the CRM app EXPOSING object via REST. Easy!

Post by Jaymer »

(forum screwed me and pissed on my long description of this)
so this will be brief

here it is

make new crm using the supplied example BSV
import this over it
publish (REST only works in LIVE mode)
hit the URLs:
https://yourserver.com/AwareIM/REST/CRM/custs
https://yourserver.com/AwareIM/REST/CRM/custs?name=All (1 cust, Jane Allison)
https://yourserver.com/AwareIM/REST/CRM/custs?name=B (2 custs, names start with B)

you modify the service to output JSON or XML

--> jaymerTip

v------ as usual, this really isn't a zip. remove the extension after download ----v
Attachments
crm_with_rest.bsv.zip
(238.14 KiB) Downloaded 803 times
Last edited by Jaymer on Sun Nov 17, 2019 9:47 pm, edited 5 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: CRM sample app w/REST

Post by Jaymer »

ok, cooler heads prevail now, with a nights sleep (and a ctrl-c to copy my post before I preview)

Tom Ford asked me for a demo in the Flutter thread - since I'd found it so easy to produce a REST service (once I knew how the Parms were accessible in Aware).
I figured using the CRM app, since it had data, would be easy.

There were 3 changes to the sample CRM app.
1) Added REST_custs - a BO with 1 field. To hold the incoming Parm "name"
2) A process "show_custs" to implement the service.
3) A service "custs" - currently outputting XML, you can change to JSON

The first time I ran it, I panicked - because it took 20-30 secs. (this was the 1st link above)
Turns out it went thru ALL the customer attributes, including Children, and output a massive amount of data.
Using the Parm, its almost instant. (using either the 2nd or 3rd link)

This underscores the need for ability to control which attributes are made available/sent/returned by the Service. I guess we have to wait for Vlad to officially say how to do this - or if this will be a future enhancement. (ex. If you only want to return a list of Customers (name, address, phone), you certainly don't want all OutgoingEmails being sent.)
NOTE: Read my reply to Henrik here where this is resolved

All in all, this was 5 minutes to do. Once there is a way to build an output view, this will certainly be more powerful.
Again, this has been discovered! It IS powerful!

Also, Vlad et. al. would have to describe how security needs to be implemented since its a public facing service, although obfuscated to the general public.
Last edited by Jaymer on Fri Apr 26, 2019 3:13 am, edited 2 times in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: CRM sample app w/REST

Post by hpl123 »

Thanks for posting this Jaymer, was a lifesaver when trying to understand how to set up a simple REST service. The documentation in this area is REALLY lousy and more documentation + a couple of examples is badly needed (hint hint support).
Henrik (V8 Developer Ed. - Windows)
Jaymer
Posts: 2430
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: CRM sample app w/REST

Post by Jaymer »

Thanks Henrik - I fotgot I even did this - and it was only 3 months ago.
Since then, I believe it was george who pointed this out to me... you can see in the above msg I said that ALL the fields were dumped by Aware. And I think the "generally accepted method" to solve that was to make a reduced attribute VIEW in the database and publish that - having put only the fields you wanted to publish into the view.
BUT, you can do that all in Aware.

This image shows a drastically reduced data view from the attached BSV. You'll notice that it no longer dumps all the contact notes, emails, etc.
Screen Shot 2019-04-25 at 12.43.22 PM.png
Screen Shot 2019-04-25 at 12.43.22 PM.png (35 KiB) Viewed 9986 times
Here's [most of] the screen that limits the objects that I wanted to send out. Edit the "custs" service, and click on the REST Setting in the property panel.
Basically, add the ones to suppress into the table. And I renamed a few also on the left table. Pretty easy... but would be tedious with tons of fields. I'm sure Vlad could improve on that if the need was there, but right now, I'm not sure many people use this or know about it.
Screen Shot 2019-04-25 at 12.43.57 PM.png
Screen Shot 2019-04-25 at 12.43.57 PM.png (39.57 KiB) Viewed 9986 times
NOTE: REST Settings Screen:: One thing you'll notice in the default output is that a few attributes [in the CRM example] near the top are output as undefined. Yet there is a Radio Button on the right side of the screen indicating DO NOT output undefined values. This might have been fixed already, but what I noticed is that if this screen is left "virgin", it was ignoring that directive. Once I put an entry in to rename Gender to Sex, then it renamed that properly AND NOW started to NOT output undefined attributes. A simple bug. And even if you don't need to rename any attributes, you can enter a dummy one without hurting anything.

glad this helped
jaymer...
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: CRM sample app w/REST

Post by hpl123 »

Jaymer wrote:Thanks Henrik - I fotgot I even did this - and it was only 3 months ago.
Since then, I believe it was george who pointed this out to me... you can see in the above msg I said that ALL the fields were dumped by Aware. And I think the "generally accepted method" to solve that was to make a reduced attribute VIEW in the database and publish that - having put only the fields you wanted to publish into the view.
BUT, you can do that all in Aware.

This image shows a drastically reduced data view from the attached BSV. You'll notice that it no longer dumps all the contact notes, emails, etc.
Screen Shot 2019-04-25 at 12.43.22 PM.png
Here's [most of] the screen that limits the objects that I wanted to send out. Edit the "custs" service, and click on the REST Setting in the property panel.
Basically, add the ones to suppress into the table. And I renamed a few also on the left table. Pretty easy... but would be tedious with tons of fields. I'm sure Vlad could improve on that if the need was there, but right now, I'm not sure many people use this or know about it.
Screen Shot 2019-04-25 at 12.43.57 PM.png
NOTE: REST Settings Screen:: One thing you'll notice in the default output is that a few attributes [in the CRM example] near the top are output as undefined. Yet there is a Radio Button on the right side of the screen indicating DO NOT output undefined values. This might have been fixed already, but what I noticed is that if this screen is left "virgin", it was ignoring that directive. Once I put an entry in to rename Gender to Sex, then it renamed that properly AND NOW started to NOT output undefined attributes. A simple bug. And even if you don't need to rename any attributes, you can enter a dummy one without hurting anything.

glad this helped
jaymer...
Nice and this helps as well so thanks for that. I originally needed a simple solution to receive a webhook so wasnt example the "correct" use of web services but I got it working. I do however need communication between Aware apps and this post with demo says it all.

PS to support. Having a webhook subscription service would be nice i.e to be able to set up a service/subscription which when called receive a JSON or other format payload and automatically map that to a BO in input/context.
Henrik (V8 Developer Ed. - Windows)
hpl123
Posts: 2579
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: DEMO: the CRM app EXPOSING object via REST. Easy!

Post by hpl123 »

Now I again tried to do this by following the documentation and NO GO. Jaymer to the rescue again.

Support, please update the documentation.....
Henrik (V8 Developer Ed. - Windows)
Post Reply