Showing posts with label #dynamics365. Show all posts
Showing posts with label #dynamics365. Show all posts

October 27, 2021

New tool: Dataverse REST Builder

Note: new version has been released, read more here or download from GitHub

If you created Web API queries against CRM/Dynamics 365/Dataverse probably you are familiar with CRM REST Builder. The amazing tool created by Jason Lattimer helped me countless times in the past years and is a tool I still use today.

The ability to generate queries (especially with Xrm.WebApi when it was introduced) comes very handy, and CRM REST Builder has several functionalities but the one most used is probably the Retrieve Multiple one.

In the past years the development of CRM REST Builder has stopped and beside some bugs the other important missing thing is the compatibility with Unified Interface.

I decided to create a new tool to replace CRM REST Builder, and Dataverse REST Builder (DRB) is finally public at this repository:

https://github.com/GuidoPreite/DRB

 It comes with a Managed Solution to install inside your instance and it will popup inside the Apps list:

As I like to test my code offline, there is also a demo mode, so you can test the application before installing the solution: https://guidopreite.github.io/DRB/

The demo data is not complete but enough to understand how the application works and the demo table  called "Custom Table" contains the majority of columns available inside a Dataverse instance.

Main differences between CRM REST Builder and Dataverse REST Builder are:

  • DRB does not support the 2011 Endpoint (so if you still need it you can continue to use CRM REST Builder)
  • DRB allows to create, save and load a collection of requests, useful if you need to store somewhere the Web API queries you created
  • Support for new columns like "Choices" (also known as Multi Select Option Sets) and better support for "Image" and "File" columns
  • Ability to create requests to execute Custom API
  • A specific request to execute a classic Workflow
  • For Retrieve Single, Create, Update, Delete, it generates also the code for Xrm.WebApi.online.execute

DRB is not perfect and probably there are some bugs as well, but the main functionalities are available and I prefer to release it and gather some feedback.

Some may ask why I decided to create a new tool and not update the existing one. Is a valid concern and I thought about it too, in the end I decided to start from scratch. Main reason is that I had already a solid base to deal with dropdowns (as in my previous tool DOSM) and I designed the application with a different approach, the fact that you can save a collection of requests divides the tool in 3 main parts: a json data structure to hold the request, a UI to manipulate the json data structure and a code generation part accepting the json data structure to create the code.

As developers we need this tool? Honestly not too much, CRM REST Builder is still a great and working tool, and Dataverse REST Builder would not exist without it, I just felt that sometimes we need to deal with new column types or new requests and it's nice to have now a tool.

Hope you find Dataverse REST Builder useful and if something is not working you can open an issue inside the GitHub repo!

September 13, 2020

Dependent Option Set Manager


tl;dr: Dependent Option Set Manager Solution (DOSM) can be downloaded here, check the demo here.

First of all, if you contacted me in the past about my previous Dependent Option Set solution and you didn't get an answer I am really sorry.
Only recently I noticed comments on this blog went directly to spam and some of them were about Dependent Option Sets, when I get messages on Twitter or LinkedIn I usually get an email notification and it's easier for me to track them.

Latest release of my previous Dependent Option Set solution was more than 2 years ago, I know it wasn't perfect but the main goal was to easily generate the required JSON, the fact that included also the script to add the functionality to a form was always secondary, I just tweaked the original script to be compatible with more Dynamics versions and with the latest release to make it compatible with Multi Select Option Sets.

If you used or still using it in some projects I am really happy for you, it means it was useful. I am not here to argue or pick a side compared to Filtered Lookups, it happens that sometimes you have Option Sets instead of Lookups (probably the main advantage is the translation of options) and it was nice to provide this functionality.

Microsoft announced Dependent Option Sets before, and I replied to someone asking me about improvements with "Microsoft will release Dependent Option Sets, I don't think I will update my solution". After a while I noticed that Microsoft removed this announcement and my solution (I repeat here, main goal was to generate the required JSON) was still used. In the last years I focused on other projects (Dynamics Weekly and PCF Gallery), I already write code during my working hours and I didn't want to write (crappy) code in public projects. Despite this, I always recognized that my Dependent Option Set solution was used and sooner or later it deserved an update.

I finally decided to spend some time on creating something new and I released Dependent Option Set Manager (DOSM), an updated version of my previous solution. Main reason of this release is the use of formContext instead of the old Xrm.Page, Unified Interface transaction is near (some customers are already using it) and it's nice to provide a fully supported version of the script.

But I wanted to do more, I thought: "How this should work for me?", upgrading the previous JavaScript to support formContext instead of Xrm.Page took me few hours, I changed some parameters, wrote some code and it was ready.
This way still require people to go manually on each form, make the changes, save and publish the form, if you already configured the previous script it's not difficult but it's a tedious process.

I wanted to provide an upgrade path, so people would install the new solution and at least they would have an option to update the forms in one way, and after I wanted to allow users to configure new options, to create new JSON Web Resources and so on.
In the end the new solution has many features so users can do everything inside the app


This forced me to work also on the script attached to the form. Yes, it works in a similar way as the script provided by Microsoft (practically an OnLoad event to load the JSON and an OnChange event for each parent field) but in addition to the code to deal with Multi Select Option Sets and the new features it's something now rewritten by me.

What are these new features?
  • Sorting, you can now decide how the values inside the Option Sets should appears (for example by Label or by Value).
  • Multiple parents, now if a Child Option Set has more than one Parent Option Set, the available options are only the intersect (quick example, for one parent the child options would be A and B, and for another parent options B and C, the only option available would be B).
Solution also included some fixes:
  • It will not trigger when a form is Disabled or Read Only (like inactive records).
  • There was a bug when more than 2 option sets were in a chain and child Option Sets were not cleared when the parent changed.

If you want to try/use the new solution you can go to the Releases under the GitHub repository to download it, and a for a demo here.

The license is MIT, means that the solution is provided "as is", no strings attached, I also tried to make clear this with the notice I wrote inside the tool:

Yes, the code is fully supported, but when dealing with Dynamics XML Forms it's a bit complicated so I needed to make you aware of that warning.

Now regarding support, if you have questions or you have problems with the solution, please open an issue here: https://github.com/GuidoPreite/DOSM/issues
It's better than contacting me directly because
  • I usually get an email when a new issue is opened
  • It's all public so everybody can see it
If in the future Microsoft decides to implement Dependent Option Sets, I only hope they will make an API available, so I can build some tool to convert my solution to the Microsoft one.

The code is public and I tried to make it as much readable as I can, there are many comments both in what the functions do and the code itself.

DOSM uses the following libraries (for the app, the Form script does not have dependencies):
  • jQuery 3.5.1
  • Bootstrap 4.5.0 (I know it's currently 4.5.2 but I didn't feel necessary to upgrade it)
  • Bootbox.js 5.4.0 (to deal with Bootstrap modals)
  • bootstrap-select 1.13.18 (I made a change on this library, the one you find inside DOSM is not the same as you download it, more details in this issue I opened in their repository)