I have a Model Driven App that needs to be able to be moved from Dev-->Stg-->Prod. As part of this, the solution connects to different SharePoint document libraries at each step. I have an environment variable to dictate what this URL is, and generally this works well. I am struggling, however, with deletion of a document in a Canvas App. I know that I could create a Power Automate to do this, but that seems overly complicated and I am hoping for a simpler solution.
Previously, all of the environment changes were handled manually and this was untenable -- it is far too easy to forget to change something in production, thus breaking prod. So, I made a change to add the SharePoint libraries for each of Dev, Stg, and Prod to the Canvas App. Then at the start of the application loading data, I determine which version I am currently working with and set that to a variable named varActiveSharePointConnector. This works perfectly for displaying the data in my gallery. However, I cannot find a way to complete a deletion because every method requires the first argument to be a Collection. When using the actual connector names, the Canvas App would let me use the Connector name as the collection, and essentially do Remove('My Connector', ThisItem);. However, when converted into a variable this does not work.
I have looked at Remove, and at Patch to do this, both require a collection as the first argument. I tried also doing a Collect(collActiveSharePoint, varActiveSharePointConnector), but then again, I cannot properly reference the SharePoint document library, only the current collection.