I usually post my NAV TechDays demo stuff for you to use and abuse, and this year won’t be an exception. There are three changes, to previous years, specially the last year. First, you won’t need to wait until New Year’s Eve for me to post my stuff. Second, I’ll blog each of the demos individually, because of the third reason. Third, I don’t want to merely dump my code here with a big fat disclaimer; no – I’ll dump it with a big fat disclaimer and some explanations about what the code does and why.
So, here we go, the first demo (actually the second, because I already posted that Muppet Theme): Customer Star Rating control add-in.
This demo is simple: it adds a factbox to the customer list page, and within that factbox it shows two star scales to rate the customer in two categories. You can select the number of stars you give the customer, and that rating is stored in
a new blob field [updated] two integer fields on the customer table. It can’t be any simpler from the surface.
- It applies the Image-As-HTML trick I blogged about yesterday (slightly different approach but minor, irrelevant differences)
- It applies the ControlReady pattern (I blogged about this one a long time ago), and how it should be done in a Business Central control add-in (by using the StartupScript, I’ll blog more about this)
- Shows how to implement interface methods declared in the control add-in object definition by exposing them from the encapsulated scope
One minor disclaimer, the demo at TechDays (as you can see in the video at https://www.youtube.com/watch?v=KnUomsA_4Jk) shows the demo in Business Central, and my screenshot here was taken in NAV 2018. Sorry for that, I couldn’t get my Docker container working after restart of my BC VM, so to be able to post this blog this morning, I had to take the screenshot from NAV 2018. Hope you don’t mind.
You can find this demo at GitHub: https://github.com/vjekob/controladdin-starrating
There are two branches:
- Branch “master”: contains the demo code for Business Central
- Branch “nav2018”: contains the same, just with the manifest (app.json) for NAV 2018 (minor, negligible differences)
And yes, the big fat disclaimer (which is actually small and thin): I provide this as-is, you are free to use it whatever way you see fit, but you can’t hold me responsible for any damage you cause to the civilization, the universe, and like (NAV and BC instances included).
This Post Has 12 Comments
You write that “that rating is stored in a new blob field”, but it’s actually stored in two Integer fields.
Yes, thanks for the correction! I apologize, I was writing off-the-top-of-my-head, and had in mind another demo that I will also blog about today, that actually uses BLOB. Thanks for pointing this out!
(And thanks for actually looking at the code, I appreciate that!)
Excellent stuff, having to find time to go through all your recent posts 🙂
One question though, works great on the webclient, but doesn’t work in the RTC client, you get the factbox but nothing renders … am i missing something?
Hm… could be that I used some ES6 feature. I don’t think so, but it could be… I’ll check.
ECMAScript 6. By the way, does it work in Internet Explorer? If it works in Internet Explorer, and does not in RTC, then it’s something else. But if it doesn’t work in Internet Explorer, then it’s most likely some ES6 feature I used inadvertently.
Hm, yes it does work in IE. Interestingly I have created my own extension to be able to use TinyMCE Html editor, that also works in on the webclient, but again not RTC Client…
Well, I have no clue, really… I’ll check. However, no promises here, RTC is on the death row anyway, and if I don’t spot it quickly, I won’t sweat much.
Just quickly looking at it, it could be that it’s failing because of the Ajax call against the local filesystem. This would mean that my HTML trick doesn’t work in RTC which I never noticed because I haven’t bothered with RTC for years, quite literally…
This seems to be the reason. Check this: https://stackoverflow.com/questions/44765702/ajax-call-to-local-file-not-working-in-ie-11
RTC embeds IE when rendering a control, and since I am using Ajax to load HTML, this fails in IE. When you load the web client in IE, then it’s no longer a local file, and it works. Maybe it happens with TinyMCE as well.
Pingback: NAV TechDays 2018 Demos: Customer Star Rating - Microsoft Dynamics NAV Community