Power Apps,  Tips and Tricks

Quick Fix – Can’t Delete That Command Bar Component Library?

Playing around with new preview features in Power Platform is a lot of fun as it shows the future potential, as well as the direction Microsoft is taking with the platform. The new Power Apps modern app commands is one of those features and I was so eager to try it for myself. So, I jumped straight onto the development environment and started configuring it on one of the existing Model-Driven apps (MDA). I realised after testing that there were some feature gaps that would prevent me from using it anytime soon and decided to delete it completely from the environment. When I tried to do this, it gave me this error message:

When I clicked on the View Dependencies button, it listed the dependent objects for this Component Library solution component:

Note: When you create a new command, a command component library is created on your behalf to store Power Fx formulas 

Those dependent objects are automatically provisioned by the platform when the command bar is added to the MDA. It’s not until these dependent objects are deleted that we can completely delete the command bar component library from the environment. OK, let the troubleshooting begin 😎

 

What Are These Dependent Objects?

When I tried to search for these tables via the standard UI, like the Solution Designer or Advanced Find, there is no hint of them. Luckily, we have the Dataverse Web API where we can quickly retrieve all the entity definitions. On a browser tab, perform a GET request [Organization URI]/api/data/v9.0/EntityDefinitions. On the returned response, find (CTRL + F) "App Action" and "Model-Driven App Element". This is what I got:

Object TypeLogical NameDescriptionWeb API Request
App ActionappactionN/A/api/data/v9.0/EntityDefinitions(LogicalName=’appaction’)
Model-Driven App ElementappelementAssociates a model-driven app with its components/api/data/v9.0/EntityDefinitions(LogicalName=’appelement’)

It is not very obvious from the entity definition what App Action is until you query GET [Organization URI]/api/data/v9.0/appactions:

{
  "@odata.context": "https://[Organization URI]/api/data/v9.0/$metadata#appactions(name,buttonlabeltext,fonticon,onclickeventformulacomponentname,onclickeventformulafunctionname,contextvalue,location)",
  "value": [
    {
      "@odata.etag": "W/\"958666\"",
      "name": "PromoteAccount!99a61e16459a46b699664b79ad23f18f",
      "buttonlabeltext": "Promote Account",
      "fonticon": "$clientsvg:Certificate",
      "onclickeventformulacomponentname": "99a61e16459a46b699664b79ad23f18f!trh_Demo!account",
      "onclickeventformulafunctionname": "OnSelect",
      "contextvalue": "account",
      "location": 0,
      "appactionid": "81877ca4-9028-405d-bd3b-a414147f6b9d"
    }
  ]
}

Looks like the App Action represents the command bar button itself. I can clearly identify that it’s the command button I placed in the Main form (location 0):

When I delete this command button via the command bar editor, the App Action dependent object disappears from the dependencies list. On to the next one!

When I query GET [Organization URI]/api/data/v9.0/appelements:

{
  "@odata.context": "https://[Organization URI]/api/data/v9.0/$metadata#appelements(solutionid,uniquename,name,canvasappid(name,displayname))",
  "value": [
    {
      "@odata.etag": "W/\"958681\"",
      "solutionid": "fd140aae-4df4-11dd-bd17-0019b9312238",
      "name": "trh_trh_Demo_canvasappid_trh_demodefaultcommandlibrary_01034",
      "appelementid": "7e1c7f49-3e2b-ec11-b6e6-00224811a7b5",
      "canvasappid": {
        "name": "trh_demodefaultcommandlibrary_01034",
        "displayname": "Demo_DefaultCommandLibrary",
        "canvasappid": "5c78d2b3-7d9e-4a20-804e-ca6bbbf1c577"
      }
    }
  ]
}

As highlighted in the response above, you can start to see the association 🤔. Except that there is no UI to delete this record.

This is where a tool like Natraj‘s Dataverse LINQPad Driver comes in handy! (I won’t go into details here on how to use this wonderful tool but do download and check it out if you haven’t yet. It will change your developer productivity level 🚀)

Now here is the important thing. You might not see this record deletion take place immediately. It varies every time I’ve tried it and it can take at least 1-5 mins to perform this operation. It could be coincidental but what I noticed that helped fast-track this is to publish the MDA after executing the delete command.

After this, you will no longer see any dependent objects listed in the dependencies and will be able to delete the command bar component library 🥳

In summary, the new modern commanding feature is still in preview and this issue which I addressed here might be something Microsoft will cater for out-of-the-box. Until then, if you have these unwanted command bar solution components in your environments then you can delete them this way!

Hope you enjoyed the post, let me know your thoughts in the comments below or any of my contact channels ðŸ˜Ž