Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / Dreaming in CRM / Importing other Notebooks i...

Importing other Notebooks in Polyglot Notebooks

I first saw Interactive Polyglot Notebooks in dotnetConf couple of years back. I immediately started thinking about all the possibilities it brings to the table for a developer. It could be used just a place to put all the code snippets by developers, or by Functional Consultants/BA for documentation with just a little code or script sprinkled here and there.

One of the recent capabilities that has been introduced in the ability to import other notebooks. I believe this is such a powerful update for re-useability and also to abstract away all the code for non-developer audience who want to start using Polyglot Notebooks. In order to demonstrate this capability, I have created a repo that shows how to use Polyglot Notebooks as a place to store all your important SQL queries.

The location of the repo is https://github.com/rajyraman/polyglot-notebook-ideas. There are two notebooks that you can look at in this repo.

SQL TDS.dib

This notebook demonstrates how to use SQL magic command to connect to the native Dataverse TDS endpoint. Since you are connecting to the native TDS endpoints not all tables will be queryable e.g., customcontrol, importjob, tracelog etc.

Interactive Notebook using native SQL magic command

SQL4CDS Queries.ipynb

This notebook shows you how you can use Mark Carrington‘s SQL 4 CDS library to query Dataverse. Since that is transpiling SQL to FetchXML, queries that cannot be run via the TDS endpoint can be run using this library. Even though the library is very well capable of running DELETEs, INSERTs and UPDATEs I have shown how to handle SELECTs only, because I wanted to demonstrate three things:

  1. How to use #!import magic command
  2. How to inject a magic command on the fly
  3. How to share variables between kernels

Polyglot Notebooks can be either created as .ipynb or .dib. I like the .ipynb format because it also saves the result. I am using notebooks as interactive documentation, so I really love this capability.

Interactive Notebooks using SQL 4 CDS

I have added this amazing renderer extension called Data Table Renderers by Taras Novak to the extension.json on the repo, so VSCode will ask you to install this extension when you open the repo. I really love this extension as it makes working on CSV and JSON data quite effective with search, sort, data analysis etc.

I hope this post has given you some ideas on how to leverage Polyglot Notebooks in your daily Power Apps/Dynamics 365 workflow. You could even potentially use this as a place to test out all your Power Fx expressions or document the various Power Platform CLI commands you use to train other developers.

Credits:

Thank you Jon Sequeira for https://github.com/dotnet/interactive/discussions/2426

Comments

*This post is locked for comments