Copilot Studio and Transforming Untyped Objects.

Introduction

The Copilot Studio experiences with UntypedObjects is a bit painful at the moment.

This article helps to show an approach that I took to be able to work with them in Copilot Studio when building Copilot Agents.

Firstly, let’s explain what an UntypedObject is. It is effectively a dynamic object which Copilot Studio does not know what the structure of it is. The object gains a dynamicProperty property which should allow you to read properties but within Copilot Studio currently that seems to go wrong.

The Problem

If you are working with data that Copilot Studio cannot resolve the type of, then you will be working with an UnTypedObject.

An example that I had was with Dataverse where I using a Environment variable to state which environment to connect to. This meant that the data that was being retrieved could not be resolved at design time and so it returned back a record of UntypedObject as shown in the screenshot below.

A screenshot of a computer  AI-generated content may be incorrect.

I tried all sorts of different approaches to see if I could make use of the object but ultimately it was the dynamicProperties property that was causing problems as Copilot Studio seemed to want to use that to convert the data and of course my real object did not have that as a property.

In the end, I stumbled on a solution using the Parse JSON activity.

A Solution

I am hoping that there are nicer solutions coming from the Copilot Studio team but this is how I turned the UntypedObject into a Typed Object.

I tried a few different approaches, including using PowerFX Types to see if I could manage the conversion of Type. However, these ended up not working or hitting syntax error issues.

Examples of PowerFX functions

As I said previously, I then stumbled on the ParseJson activity.

Using the ParseJson Copilot Studio activity, along with a copy of the JSON string object, helped me get over the issues.

Here is what I did. First of all I outputted the whole table to a message using a Send Message activity, as shown below.

A screenshot of a computer  AI-generated content may be incorrect.

Then, I copied an example of the Json and used that with the ParseJson activity.

A screenshot of a computer  AI-generated content may be incorrect.

Here is the schema for the Parse JSON activity.

A screenshot of a computer  AI-generated content may be incorrect.

The output of the ParseJson gave me a variable with a known shape.

Now that I have a variable with a known type, we are golden and everything is working as you would expect.

The data can be used as normal with other activities, such as Power Automate.

A screenshot of a computer  AI-generated content may be incorrect.

Problem solved!

Conclusion

As we spend more time working on Copilot Studio solutions, I am sure these experiences will improve. Anyway, I hope you stumble on this and it helps you out.

I spent a few hours trying different things and ultimately found this solution.

Thanks for reading.

Thoughts? Comments about this post? Please leave them here..

This site uses Akismet to reduce spam. Learn how your comment data is processed.