{"id":1184,"date":"2024-11-11T11:00:00","date_gmt":"2024-11-11T16:00:00","guid":{"rendered":"https:\/\/automatethemundane.com\/index.php\/2024\/11\/11\/updating-dataverse-records-and-business-process-flows-bpf-with-copilot-studio\/"},"modified":"2024-11-12T08:08:40","modified_gmt":"2024-11-12T13:08:40","slug":"updating-dataverse-records-and-business-process-flows-bpf-with-copilot-studio","status":"publish","type":"post","link":"https:\/\/automatethemundane.com\/index.php\/2024\/11\/11\/updating-dataverse-records-and-business-process-flows-bpf-with-copilot-studio\/","title":{"rendered":"Updating Dataverse Records and Business Process Flows (BPF) with Copilot Studio"},"content":{"rendered":"\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">In a recent project, I was challenged to try and build a Copilot in Copilot Studio that would update a Dataverse table AND update a Business Process Flow (BPF). On its face, its not too crazy. These are classic components of the Power Platform. However, after a few days, it turned into quite the endeavor. One thing that kept sticking for me was I wanted any flows\/topics\/actions connected with the Co Pilot to be dynamic in nature so it could be used over and over. This will be a LONG post as it requires quite a few setup and configuration items, but it is well worth running through it.<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The example will be that of a somebody who manages a 3D Printing business (I love 3D printing) via Dataverse and Model Driven apps. The co pilot will allow the user to get the status of a print job from the database and update its associated BPF. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Initial Configuration<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Dataverse Table<\/h2>\n\n\n\n<div class=\"wp-block-wp-mermaid-block mermaid\">\n---\ntitle: Project ERD\n---\nerDiagram\n    Prints }| -- || Contacts :contains\n    Prints }| -- |{ PrintJobsBPF:contains\n    PrintJobsBPF{\n        int EntraID PK\n        }\n    Contacts{\n        int Person PK\n        }\n     Prints {\n        string PrintJob PK\n        lookup Requestor FK\n        lookup BPF FK\n        string PrintItem\n        int Quanity\n        boolean PrintCompleted\n        date DateRequested\n        date DateStarted\n        date DateCompleted\n    }\n<\/div>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BPF<\/h2>\n\n\n\n<div class=\"wp-block-wp-mermaid-block mermaid\">\nflowchart LR\n  A(Request) --> B(Printing)\n  B --> C(Completed)\n<\/div>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-1024x279.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Keys<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Create a key for the print job column to ensure no names are unique<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-1.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Views<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-2.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Form<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-3-1024x648.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">App<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-4-1024x510.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-5-1024x510.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Classic Workflows<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">I use classic workflows when I manage BPF automatically moving between stages. It can be done with Power Automate, but I find this much easier. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Move BPF from Request to Printing<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a new Classic workflow that is attached to the BPF table\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-6.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Set the conditions to be the based on the related table (Prints), then set the date requested and created on to contains data. Also, set the Active stage to equals Request\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-7-1024x257.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Add an Update step for the BPF table, then select \u201cSet Properties\u201d\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-8-1024x116.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Set the Active Stage to Printing\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-9-1024x430.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Then convert the workflow to a real time workflow\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-10-1024x401.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Save and Activate the Workflow<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With the workflow in place, the BPF will move forward shortly after the record is created. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Move BPF from Printing to Completed<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>As with the step before, create a new workflow background workflow\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-11.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Set the condition to be the same as the BPF stage itself and the active stage to Printing\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-12-1024x233.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>App an update step to put the BPF in the completed Stage status to Inactive\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-13-1024x270.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Then, add another update stage that updates the Prints table Status column to Inactive\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-14-1024x476.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Update the Starts when to Process changes\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-15-1024x248.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Using the Prints table, set the Update if Date Completed\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-16.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Save and Active the workflow<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Copilot Studio <\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Setup<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">When building out this Copilot, I tried using straight generative AI with knowledge, Topics connected to flows, and actions connected with flows. I wanted the ability for a user to query a job, get the BPF stage and its steps, then update it. I landed on using topics with power automate flows and generative AI enabled. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Knowledge<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">I built out two knowledge sources, one for just the prints table and one for the BPF table and its associated tables. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-17-1024x126.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-18.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-19.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Topic 1 - Get BPF info<\/h2>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The first topic will reach out to the Prints table, gets associated BPF record, and give the information back to the user. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The trigger will be from copilot\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-20.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>The user is then asked for the name of the print job. The output is saved in variable \u201cvarResponsePrintjobname\u201d\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-21.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>A message is sent to the user letting them know the action is running\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-22.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>A Power Automate flow is then executed. I will show how to build this next.\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-23.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Three global variables are set from the output of the flows. I chose to do this instead of saving the topic variable as global because I find responses in the chat are \u201cbetter\u201d if they are Topic only. <\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-24.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Power Automate flow - Get BPF Information for Copilot<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a Power Automate workflow called Get BPF Information for Copilot with a Copilot trigger. <\/li>\n\n\n\n<li>Add a text input called Print Job Name\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-25-1024x317.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Add four variables, two string variables, and two array variables\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-26.png\" alt=\"\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>varEntityLogicalName - String<\/li>\n\n\n\n<li>varCurrentStageName - String<\/li>\n\n\n\n<li>varStagesArray - Array<\/li>\n\n\n\n<li>varStepArray - Array<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Using a List Rows filter, the table using FetchXML ( I find it easier)\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-27-1024x438.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;fetch&gt;\n  &lt;entity name=\"andy_prints\"&gt;\n    &lt;filter&gt;\n      &lt;condition attribute=\"andy_printjob\" operator=\"eq\" value=\"\" \/&gt;\n    &lt;\/filter&gt;\n  &lt;\/entity&gt;\n&lt;\/fetch&gt;<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Using another list rows, do a FetchXML to find the BPF row based on the associated Print row\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-28-1024x491.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>outputs('List_rows_-_Prints')?&#91;'body\/value']?&#91;0]?&#91;'andy_printsid']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:rgb(241, 241, 239)\">\ud83d\udca1 The next part should be built out as a child flow for production purposes so it can be reused. But for this demo i put it all into one flow<\/p>\n<\/li>\n\n\n\n<li>Create vars<\/li>\n\n\n\n<li>Create another Scope called \u201cScope - Process Stage\u201d<\/li>\n\n\n\n<li>Within the Scope there will be two actions<\/li>\n\n\n\n<li>The First Action \u201cGet a row by ID - Process Stages\u201d, will use the outputs of the List rows - BPF to get the process stages of the BPF\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-29-1024x418.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>outputs('List_rows_-_BPF')?&#91;'body']?&#91;'value']&#91;0]?&#91;'_activestageid_value']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>The second will compose the active stage display name\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-30-1024x360.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-background\" style=\"background-color:rgb(241, 241, 239)\">\ud83d\udca1 This is where the complications of BPF stages and steps come into play. To get the steps of a BPF we need to parse the workflows table and get the clientdata of the row. This is a JSON stored as a string. It is comprised of StageSteps (BPF Stages) and StepSteps (the BPF data steps). We need this information so that we can send it back to copilot and inform the user what stage its at and the steps that need to be taken to update it. <\/p>\n<\/li>\n\n\n\n<li>Next, add parallel Dataverse action to get the the workflow information\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-31.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Add a Dataverse, get row by ID, and use the process ID gathered above\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-32-1024x225.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>outputs('List_rows_-_BPF')?&#91;'body']?&#91;'value']&#91;0]?&#91;'_processid_value']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Nex,t will be a ParseJSON of the outputs clientdata\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-33-1024x307.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"type\": \"object\",\n    \"properties\": {\n        \"__class\": {\n            \"type\": \"string\"\n        },\n        \"id\": {\n            \"type\": \"string\"\n        },\n        \"description\": {\n            \"type\": \"string\"\n        },\n        \"name\": {\n            \"type\": \"string\"\n        },\n        \"stepLabels\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"list\": {\n                    \"type\": \"array\"\n                }\n            }\n        },\n        \"steps\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"list\": {\n                    \"type\": \"array\",\n                    \"items\": {\n                        \"type\": \"object\",\n                        \"properties\": {\n                            \"__class\": {\n                                \"type\": \"string\"\n                            },\n                            \"id\": {\n                                \"type\": \"string\"\n                            },\n                            \"description\": {\n                                \"type\": \"string\"\n                            },\n                            \"name\": {\n                                \"type\": \"string\"\n                            },\n                            \"stepLabels\": {\n                                \"type\": \"object\",\n                                \"properties\": {\n                                    \"list\": {\n                                        \"type\": \"array\"\n                                    }\n                                }\n                            },\n                            \"steps\": {\n                                \"type\": \"object\",\n                                \"properties\": {\n                                    \"list\": {\n                                        \"type\": \"array\"\n                                    }\n                                }\n                            },\n                            \"relationshipName\": {},\n                            \"attributeName\": {},\n                            \"isClosedLoop\": {\n                                \"type\": \"boolean\"\n                            }\n                        },\n                        \"required\": &#91;\n                            \"__class\",\n                            \"id\",\n                            \"description\",\n                            \"name\",\n                            \"stepLabels\",\n                            \"steps\"\n                        ]\n                    }\n                }\n            }\n        },\n        \"primaryEntityName\": {\n            \"type\": \"string\"\n        },\n        \"nextStepIndex\": {\n            \"type\": \"string\"\n        },\n        \"isCrmUIWorkflow\": {\n            \"type\": \"boolean\"\n        },\n        \"category\": {\n            \"type\": \"string\"\n        },\n        \"businessProcessType\": {\n            \"type\": \"string\"\n        },\n        \"mode\": {\n            \"type\": \"string\"\n        },\n        \"title\": {\n            \"type\": \"string\"\n        },\n        \"workflowEntityId\": {\n            \"type\": \"string\"\n        },\n        \"formId\": {},\n        \"argumentsArray\": {\n            \"type\": \"array\"\n        },\n        \"variables\": {\n            \"type\": \"array\"\n        },\n        \"inputs\": {\n            \"type\": \"array\"\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>A filter array is used to filter the clientdata so only the steps are given and no other parts of the data. To do this, we need to convert the list data into an array then filter it\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-34-1024x375.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>array(body('Parse_JSON_-_Workflow_Client_data')?&#91;'steps']?&#91;'list'])<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>equals(item()?&#91;'__class'], 'EntityStep:#Microsoft.Crm.Workflow.ObjectModel')<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Then, we can set the Entity logical name\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-35-1024x283.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>outputs('Filter_array_-_For_Steps')&#91;'body']?&#91;0]?&#91;'description']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>To get the steps within the array, we now add an apply to each and use the body of the filter array - for steps<\/li>\n\n\n\n<li>Configure the Apply to each to run after the setting of the variable and the compose of the stage name. The Apply to each will loop over each item from the Filter array - For Steps\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-36-1024x353.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Add an append to array variable that will add the stage and the steps to the variable  - varStagearray\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-37-1024x297.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>item()?&#91;'steps']?&#91;'list']?&#91;0]?&#91;'description']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>item()?&#91;'steps']?&#91;'list']?&#91;0]?&#91;'steps']?&#91;'list']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>With an array of the stages and steps, we now clean the steps so we can send a \u201cclean\u201d list to Copilot Studio to show the user the exact stage and steps. To do this, we will do another For Each loop within the true leg of the condition.<\/li>\n\n\n\n<li>Before we can do the loop though, add in a parse JSON to access the array a bit easier, then add the loop and another append to array variable. \n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-38.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Set the variable varCurrentStageName with the current stage name\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-39-1024x351.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>The last step of the flow is to respond to the Copilot with the current Stage\/Step\/Current table\/RecordGUID\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-40-1024x389.png\" alt=\"\"\/><\/figure>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"has-background\" style=\"background-color:rgb(241, 241, 239)\">\ud83d\udca1 It is important to give the responses to Copilot good names along with good descriptions <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"type\": \"Response\",\n  \"kind\": \"Skills\",\n  \"inputs\": {\n    \"schema\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"current_status\": {\n          \"title\": \"Current Status\",\n          \"description\": \"This is the current stage being used in the business process flow\",\n          \"type\": \"string\",\n          \"x-ms-content-hint\": \"TEXT\",\n          \"x-ms-dynamically-added\": true\n        },\n        \"list_of steps to complete\": {\n          \"title\": \"List of Steps to Complete\",\n          \"description\": \"These are the current steps within the current stage of the business process flow\",\n          \"type\": \"string\",\n          \"x-ms-content-hint\": \"TEXT\",\n          \"x-ms-dynamically-added\": true\n        },\n        \"prints_table logical name\": {\n          \"title\": \"Prints Table Logical Name\",\n          \"description\": \"\",\n          \"type\": \"string\",\n          \"x-ms-content-hint\": \"TEXT\",\n          \"x-ms-dynamically-added\": true\n        },\n        \"print_record guid\": {\n          \"title\": \"Print Record GUID\",\n          \"description\": \"\",\n          \"type\": \"string\",\n          \"x-ms-content-hint\": \"TEXT\",\n          \"x-ms-dynamically-added\": true\n        }\n      },\n      \"additionalProperties\": {}\n    },\n    \"statusCode\": 200,\n    \"body\": {\n      \"current_status\": \"@{variables('varCurrentStageName')}\",\n      \"list_of steps to complete\": \"@{variables('varStepArray')}\",\n      \"prints_table logical name\": \"@{variables('varEntityLogicalName')}\",\n      \"print_record guid\": \"@{outputs('List_rows_-_Prints')?&#91;'body\/value']?&#91;0]?&#91;'andy_printsid']}\"\n    }\n  },\n  \"runAfter\": {\n    \"Scope_-_Process_Stage_and_Workflows\": &#91;\n      \"Succeeded\"\n    ]\n  }\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">To test the co pilot, I have added 30 records<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Print Job<\/strong><\/td><td><strong>Requestor<\/strong><\/td><td><strong>Print Item<\/strong><\/td><td><strong>Quanity<\/strong><\/td><\/tr><tr><td>Print Job 1<\/td><td>Jim Henson<\/td><td>Kermit the Frog<\/td><td>3<\/td><\/tr><tr><td>Print Job 10<\/td><td>Jim Henson<\/td><td>Dr. Bunsen Honeydew<\/td><td>25<\/td><\/tr><tr><td>Print Job 11<\/td><td>Jim Henson<\/td><td>Beaker<\/td><td>60<\/td><\/tr><tr><td>Print Job 12<\/td><td>Jim Henson<\/td><td>Scooter<\/td><td>13<\/td><\/tr><tr><td>Print Job 13<\/td><td>Jim Henson<\/td><td>Rizzo the Rat<\/td><td>70<\/td><\/tr><tr><td>Print Job 14<\/td><td>Jim Henson<\/td><td>Sam Eagle<\/td><td>2<\/td><\/tr><tr><td>Print Job 15<\/td><td>Jim Henson<\/td><td>Sweetums<\/td><td>45<\/td><\/tr><tr><td>Print Job 16<\/td><td>Jim Henson<\/td><td>Dr. Teeth<\/td><td>27<\/td><\/tr><tr><td>Print Job 17<\/td><td>Jim Henson<\/td><td>Floyd Pepper<\/td><td>39<\/td><\/tr><tr><td>Print Job 18<\/td><td>Jim Henson<\/td><td>Janice<\/td><td>9<\/td><\/tr><tr><td>Print Job 19<\/td><td>Jim Henson<\/td><td>Zoot<\/td><td>50<\/td><\/tr><tr><td>Print Job 2<\/td><td>Jim Henson<\/td><td>Miss Piggy<\/td><td>15<\/td><\/tr><tr><td>Print Job 20<\/td><td>Jim Henson<\/td><td>Camilla the Chicken<\/td><td>6<\/td><\/tr><tr><td>Print Job 21<\/td><td>Jim Henson<\/td><td>Robin the Frog<\/td><td>73<\/td><\/tr><tr><td>Print Job 22<\/td><td>Jim Henson<\/td><td>Crazy Harry<\/td><td>30<\/td><\/tr><tr><td>Print Job 23<\/td><td>Jim Henson<\/td><td>Lew Zealand<\/td><td>1<\/td><\/tr><tr><td>Print Job 24<\/td><td>Jim Henson<\/td><td>Mahna Mahna<\/td><td>12<\/td><\/tr><tr><td>Print Job 25<\/td><td>Jim Henson<\/td><td>Pepe the King Prawn<\/td><td>42<\/td><\/tr><tr><td>Print Job 26<\/td><td>Jim Henson<\/td><td>Beauregard<\/td><td>18<\/td><\/tr><tr><td>Print Job 27<\/td><td>Jim Henson<\/td><td>Clifford<\/td><td>58<\/td><\/tr><tr><td>Print Job 28<\/td><td>Jim Henson<\/td><td>Link Hogthrob<\/td><td>14<\/td><\/tr><tr><td>Print Job 29<\/td><td>Jim Henson<\/td><td>Marvin Suggs<\/td><td>67<\/td><\/tr><tr><td>Print Job 3<\/td><td>Jim Henson<\/td><td>Fozzie Bear<\/td><td>22<\/td><\/tr><tr><td>Print Job 30<\/td><td>Jim Henson<\/td><td>Uncle Deadly<\/td><td>31<\/td><\/tr><tr><td>Print Job 4<\/td><td>Jim Henson<\/td><td>Gonzo the Great<\/td><td>5<\/td><\/tr><tr><td>Print Job 5<\/td><td>Jim Henson<\/td><td>Animal<\/td><td>48<\/td><\/tr><tr><td>Print Job 6<\/td><td>Jim Henson<\/td><td>Rowlf the Dog<\/td><td>7<\/td><\/tr><tr><td>Print Job 7<\/td><td>Jim Henson<\/td><td>Statler<\/td><td>34<\/td><\/tr><tr><td>Print Job 8<\/td><td>Jim Henson<\/td><td>Waldorf<\/td><td>69<\/td><\/tr><tr><td>Print Job 9<\/td><td>Jim Henson<\/td><td>The Swedish Chef<\/td><td>11<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With just this data and the current topic on here is my test, ask how many jobs there are, get some basic info on a job, then get the BPF status<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-41-1024x501.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-42-1024x536.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-43.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-44.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">We now have a good extraction of the stage and steps. The next step will be to allow the user to update the BPF via copilot. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Topic 2 - Get Column Info<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Topic flow - Part 1<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With the columns returned, we now need to get the types when then user asks to update the record. This could have been done during the last flow, but for the sake of speed, I decided to run it after a user asks for it. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a trigger and a message for the user. The trigger will be called if the user asks to update the record. The message will let the user know its working. \n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-45.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Run a Power Automate flow that will give us the column types out put (the guide for the flow is next)\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-46.png\" alt=\"\"\/><\/figure>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Power Automate flow - Get Column info from Copilot<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">This next flow will get the column information that was gathered from the previous flow. This is important because we don't just want to get the information into the bot, we want to write updates back to the BPF.  <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The trigger will be a run from copilot with two text inputs, Table and steps\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-47-1024x228.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>The next step is to do a Parse JSON of the steps then to initialize a new variable array called vatTypes\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-48-1024x382.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"type\": \"array\",\n    \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n            \"StepName\": {\n                \"type\": \"string\"\n            },\n            \"StepLogicalName\": {\n                \"type\": \"string\"\n            }\n        },\n        \"required\": &#91;\n            \"StepName\",\n            \"StepLogicalName\"\n        ]\n    }\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>To get the column type we need to run an HTTP request to Dataverse that will sit in a for each loop of the steps, I like to use the HTTP with Microsoft Entra ID (preauthorized)\n\n\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-49.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-50-1024x278.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>body('Parse_JSON_-_Steps')?&#91;0]?&#91;'stepList']<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-51.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/api\/data\/v9.2\/EntityDefinitions(LogicalName='@{triggerBody()?&#91;'text']}')\/Attributes(LogicalName='@{items('Apply_to_each_-_each_step')&#91;'StepLogicalName']}')<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Add an append to array action that add the following\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-52-1024x213.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"columnname\": @{items('Apply_to_each_-_each_step')?&#91;'StepLogicalName']},\n  \"value\": @{body('Invoke_an_HTTP_request')?&#91;'AttributeTypeName']?&#91;'Value']},\n  \"output\": \"\",\n  \"DisplayName\": @{items('Apply_to_each_-_each_step')?&#91;'StepName']}\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Within the respond to Copilot add the varTypes to the columntypes output\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-53-1024x397.png\" alt=\"\"\/><\/figure>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Topic flow - Part 2<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Parse the variable to save it as a table\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-54.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>kind: Table\nproperties:\n  columnname: String\n  DisplayName: String\n  output: String\n  value: String<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Then post a question to the user on the type of column to be updated\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-55.png\" alt=\"\"\/><\/figure>\n<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Testing<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With that we can now get a list of options to update in the chat<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-56.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Topic flow - Part 3 Update record<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With all this information, we can now run a flow to update the record. However, since we do not know the table, or the column name, nor the column type until the user request it from the chat, we need to make a dynamic update process. <\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">There are a total of 28 data verse column types <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-apps\/maker\/data-platform\/types-of-fields\">Column data types in Microsoft Dataverse - Power Apps | Microsoft Learn<\/a><\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Name<\/th><th>Type<\/th><th>Data<\/th><\/tr><\/thead><tbody><tr><td><strong>Big<\/strong><\/td><td><strong>Time Stamp<\/strong><\/td><td><code>BigIntType<\/code><\/td><\/tr><tr><td><strong>Choice<\/strong><\/td><td><strong>Option Set<\/strong><\/td><td><code>PicklistType<\/code><\/td><\/tr><tr><td><strong>Choices<\/strong><\/td><td><strong>MultiSelect Field<\/strong><\/td><td><code>MultiSelectPicklistType<\/code><\/td><\/tr><tr><td><strong>Currency<\/strong><\/td><td><strong>Currency<\/strong><\/td><td><code>MoneyType<\/code><\/td><\/tr><tr><td><strong>Customer<\/strong><\/td><td><strong>Customer<\/strong><\/td><td><code>CustomerType<\/code><\/td><\/tr><tr><td><strong>Date and Time<\/strong><\/td><td><strong>Date and Time <\/strong><em>Date and Time<\/em>&nbsp;Format<\/td><td><code>DateTimeType<\/code><\/td><\/tr><tr><td><strong>Date Only<\/strong><\/td><td><strong>Date and Time <\/strong><em>Date Only<\/em>&nbsp;Format<\/td><td><code>DateTimeType<\/code><\/td><\/tr><tr><td><strong>Decimal Number<\/strong><\/td><td><strong>Decimal Number<\/strong><\/td><td><code>DecimalType<\/code><\/td><\/tr><tr><td><strong>Duration<\/strong><\/td><td><strong>Whole Number <\/strong><em>Duration<\/em>&nbsp;Format<\/td><td><code>IntegerType<\/code><\/td><\/tr><tr><td><strong>Email<\/strong><\/td><td><strong>Single Line of Text <\/strong><em>Email<\/em>&nbsp;Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>File<\/strong><\/td><td><strong>File<\/strong><\/td><td><code>FileType<\/code><\/td><\/tr><tr><td><strong>Floating Point Number<\/strong><\/td><td><strong>Floating Point Number<\/strong><\/td><td><code>DoubleType<\/code><\/td><\/tr><tr><td><strong>Image<\/strong><\/td><td><strong>Image<\/strong><\/td><td><code>ImageType<\/code><\/td><\/tr><tr><td><strong>Language<\/strong><\/td><td><strong>Whole Number <\/strong><em>Language<\/em>&nbsp;Format<\/td><td><code>IntegerType<\/code><\/td><\/tr><tr><td><strong>Lookup<\/strong><\/td><td><strong>Lookup<\/strong><\/td><td><code>LookupType<\/code><\/td><\/tr><tr><td><strong>Multiline Text<\/strong><\/td><td><strong>Multiple Lines of Text<\/strong><\/td><td><code>MemoType<\/code><\/td><\/tr><tr><td><strong>Owner<\/strong><\/td><td><strong>Owner<\/strong><\/td><td><code>OwnerType<\/code><\/td><\/tr><tr><td><strong>Phone<\/strong><\/td><td><strong>Single Line of Text <\/strong><em>Phone<\/em>&nbsp;Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>Status<\/strong><\/td><td><strong>Status<\/strong><\/td><td><code>StateType<\/code><\/td><\/tr><tr><td><strong>Status Reason<\/strong><\/td><td><strong>Status Reason<\/strong><\/td><td><code>StatusType<\/code><\/td><\/tr><tr><td><strong>Text<\/strong><\/td><td><strong>Single Line of Text <\/strong><em>Text<\/em>&nbsp;Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>Text Area<\/strong><\/td><td><strong>Single Line of Text <\/strong><em>Text Area<\/em>&nbsp;Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>Ticker Symbol<\/strong><\/td><td><strong>Single Line of Text <\/strong>Ticker Symbol Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>Timezone<\/strong><\/td><td><strong>Whole Number <\/strong><em>Time Zone<\/em>&nbsp;Format<\/td><td><code>IntegerType<\/code><\/td><\/tr><tr><td><strong>Unique Identifier<\/strong><\/td><td><strong>Unique Identifier<\/strong>&nbsp;or&nbsp;<strong>Primary Key<\/strong><\/td><td><code>UniqueidentifierType<\/code><\/td><\/tr><tr><td><strong>URL<\/strong><\/td><td><strong>Single Line of Text <\/strong><em>URL<\/em>&nbsp;Format<\/td><td><code>StringType<\/code><\/td><\/tr><tr><td><strong>Whole Number<\/strong><\/td><td><strong>Whole Number <\/strong><em>None<\/em>&nbsp;Format<\/td><td><code>IntegerType<\/code><\/td><\/tr><tr><td><strong>Yes\/No<\/strong><\/td><td><strong>Two Options<\/strong><\/td><td><code>BooleanType<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">With this information, we can build a set of flows that will update the appropriate data type. For the example I will build out three types, Date\/String\/Boolean.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add three conditions to handle the data types\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-57-1024x486.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>Under the Boolean condition add a ask with adaptive card action\n\n<pre class=\"wp-block-code\"><code>{\n    \"type\": \"AdaptiveCard\",\n    \"$schema\": \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n    \"version\": \"1.5\",\n    \"body\": &#91;\n        {\n            \"type\": \"Container\",\n            \"items\": &#91;\n                {\n                    \"type\": \"Input.Toggle\",\n                    \"title\": \"TITLE\",\n                    \"id\": \"varRequestupdateboolean\"\n                }\n            ]\n        },\n        {\n            \"type\": \"ActionSet\",\n            \"actions\": &#91;\n                {\n                    \"type\": \"Action.Submit\",\n                    \"title\": \"Submit\",\n                    \"style\": \"positive\",\n                    \"id\": \"SubmitOutput\"\n                }\n            ]\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Since this is Copilot studio, we can update the card to be dynamic with Power FX. So that the title is the display name of the column\n\n<pre class=\"wp-block-code\"><code>{\n  type: \"AdaptiveCard\",\n  '$schema': \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n  version: \"1.5\",\n  body: &#91;\n    {\n      type: \"Container\",\n      items: &#91;\n        {\n          type: \"Input.Toggle\",\n          title: Topic.varRequestedUpdate.DisplayName,\n          id: \"varRequestupdateboolean\"\n        }\n      ]\n    },\n    {\n      type: \"ActionSet\",\n      actions: &#91;\n        {\n          type: \"Action.Submit\",\n          title: \"Submit\",\n          style: \"positive\",\n          id: \"SubmitOutput\"\n        }\n      ]\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>For the Date add this adaptive card\n\n<pre class=\"wp-block-code\"><code>{\n    \"type\": \"AdaptiveCard\",\n    \"$schema\": \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n    \"version\": \"1.5\",\n    \"body\": &#91;\n        {\n            \"type\": \"Container\",\n            \"items\": &#91;\n                {\n                    \"type\": \"Input.Date\",\n                    \"id\": \"varRequestupdatedate\",\n                    \"label\": \"Title\"\n                }\n            ]\n        },\n        {\n            \"type\": \"ActionSet\",\n            \"actions\": &#91;\n                {\n                    \"type\": \"Action.Submit\",\n                    \"title\": \"Submit\",\n                    \"style\": \"positive\",\n                    \"id\": \"SubmitOutput\"\n                }\n            ]\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Then update the card to use the following Power FX\n\n<pre class=\"wp-block-code\"><code>{\n  type: \"AdaptiveCard\",\n  '$schema': \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n  version: \"1.5\",\n  body: &#91;\n    {\n      type: \"Container\",\n      items: &#91;\n        {\n          type: \"Input.Date\",\n          id: \"varRequestupdatedate\",\n          label: Topic.varRequestedUpdate.DisplayName\n        }\n      ]\n    },\n    {\n      type: \"ActionSet\",\n      actions: &#91;\n        {\n          type: \"Action.Submit\",\n          title: \"Submit\",\n          style: \"positive\",\n          id: \"SubmitOutput\"\n        }\n      ]\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>For the string type use this card\n\n<pre class=\"wp-block-code\"><code>{\n    \"type\": \"AdaptiveCard\",\n    \"$schema\": \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n    \"version\": \"1.5\",\n    \"body\": &#91;\n        {\n            \"type\": \"Container\",\n            \"items\": &#91;\n                {\n                    \"type\": \"Input.Text\",\n                    \"placeholder\": \"Placeholder text\",\n                    \"id\": \"varRequestupdatestring\",\n                    \"label\": \"TITLE\"\n                }\n            ]\n        },\n        {\n            \"type\": \"ActionSet\",\n            \"actions\": &#91;\n                {\n                    \"type\": \"Action.Submit\",\n                    \"title\": \"Submit\",\n                    \"style\": \"positive\",\n                    \"id\": \"SubmitOutput\"\n                }\n            ]\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>Then update it with the following PowerFX\n\n<pre class=\"wp-block-code\"><code>{\n  type: \"AdaptiveCard\",\n  '$schema': \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\n  version: \"1.5\",\n  body: &#91;\n    {\n      type: \"Container\",\n      items: &#91;\n        {\n          type: \"Input.Text\",\n          placeholder: \"\",\n          id: \"varRequestupdatestring\",\n          label: Topic.varRequestedUpdate.DisplayName\n        }\n      ]\n    },\n    {\n      type: \"ActionSet\",\n      actions: &#91;\n        {\n          type: \"Action.Submit\",\n          title: \"Submit\",\n          style: \"positive\",\n          id: \"SubmitOutput\"\n        }\n      ]\n    }\n  ]\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>With the cards created we can now run the flows. There will be a flow per each condition. For the example given here, I will show how to build the date update flow. I am going to do another post on how to handle each column type later.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Power Automate - Update DateTime Flow<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a flow with four text inputs and one date input\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-58-1024x274.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>The two HTTP requests will be added. The first will be used to get the entity set name and the second will be used to preform the update\n\n\n\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-59-1024x236.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/api\/data\/v9.0\/EntityDefinitions?$filter=LogicalName eq '@{triggerBody()?&#91;'text_2']}'&amp;$select=EntitySetName<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-60-1024x523.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/api\/data\/v9.2\/@{body('Invoke_an_HTTP_request_-_Get_entityset_name')?&#91;'value']?&#91;0]?&#91;'EntitySetName']}(@{triggerBody()?&#91;'text_3']})<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  @{triggerBody()?&#91;'text']}:\"@{triggerBody()?&#91;'date']}\"\n}d<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>This will be closed out by an empty respond to co pilot action<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Within the studio, add the call flow action. For the date ensure to wrap it in the date value PowerFX formula <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Text(DateValue(Topic.varRequestupdatedate), \"yyyy-mm-dd\")<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-61.png\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Power Automate - Update Boolean<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The flow will be very similar to the one above with the biggest difference being that the trigger will use a Boolean vs a date<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add the trigger with the following inputs\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-62-1024x399.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>As before, add two http actions, on to get the entity set name and one to preform the patch\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-63-1024x347.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/api\/data\/v9.2\/@{body('Invoke_an_HTTP_request_-_Get_entityset_name')?&#91;'value']?&#91;0]?&#91;'EntitySetName']}(@{triggerBody()?&#91;'text_3']})<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  @{triggerBody()?&#91;'text']}: \"@{triggerBody()?&#91;'boolean']}\"\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>This will be closed out by an empty respond to co pilot action<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">Within the studio add the call flow action. For the date ensure to wrap it in the datevalue PowerFX formula<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>If(Topic.varRequestupdateboolean= \"True\", true, false)<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-64.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Power Automate - Update String<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Add the trigger with the following inputs\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-65-1024x269.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>As add two http actions, on to get the entity set name and one to preform the patch\n\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-66-1024x390.png\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/api\/data\/v9.2\/@{body('Invoke_an_HTTP_request_-_Get_entityset_name')?&#91;'value']?&#91;0]?&#91;'EntitySetName']}(@{triggerBody()?&#91;'text_3']})<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  @{triggerBody()?&#91;'text']}: \"@{triggerBody()?&#91;'text_4']}\"\n}<\/code><\/pre>\n\n\n\n<p>&nbsp;<\/p>\n<\/li>\n\n\n\n<li>This will be closed out by an empty respond to co pilot action<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Topic flow - Part 4 Close it out and loopback<\/h3>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">The last step will be to ask the user if there are any other fields to update<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>After all the conditions, add a question that asks the user if there are any other fields to update\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-67.png\" alt=\"\"\/><\/figure>\n<\/li>\n\n\n\n<li>If the output is true loop back to the Question \u201cWhat would you like to update\u201d, else end the conversation.\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-68.png\" alt=\"\"\/><\/figure>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-69.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-70.png\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-71-1024x370.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-72.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/image-73-1024x369.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">&nbsp;<\/p>\n\n\n\n<p class=\"has-text-color\" style=\"color:rgb(0, 0, 0)\">I think there are quite a few things that can be done to improve this. I really want to get the generative flows along with less reliance on Power Automate. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a recent project, I was challenged to try and build a Copilot in Copilot Studio that would update a Dataverse table AND update a Business Process Flow (BPF). On its face, its not too crazy. These are classic components of the Power Platform. However, after a few days, it turned into quite the endeavor. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1180,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,49,50,22,30,35],"tags":[],"class_list":["post-1184","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-business-process-flow","category-copilot","category-copilot-studio","category-dataverse","category-power-automate","category-tables","entry","has-media"],"jetpack_featured_media_url":"https:\/\/automatethemundane.com\/wp-content\/uploads\/2024\/11\/photo-1549969341-853262338e07-scaled.jpg","_links":{"self":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/1184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/comments?post=1184"}],"version-history":[{"count":3,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/1184\/revisions"}],"predecessor-version":[{"id":1189,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/posts\/1184\/revisions\/1189"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/media\/1180"}],"wp:attachment":[{"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/media?parent=1184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/categories?post=1184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/automatethemundane.com\/index.php\/wp-json\/wp\/v2\/tags?post=1184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}