From 4591c254c7903878ad7b0483d7de053ab5bae02d Mon Sep 17 00:00:00 2001 From: Max Ewing Date: Wed, 6 Jan 2021 16:33:05 +0000 Subject: [PATCH] fix: unauthorised error in merge flow (#54) --- scripts/Add-BuildTagForEachUpdatedSolution.ps1 | 6 +++--- .../Extract/AppModules/devhub_DevelopmentHub/AppModule.xml | 2 +- .../AppModules/devhub_DevelopmentHub/AppModule_managed.xml | 2 +- .../Extract/Other/Solution.xml | 4 ++-- ...Getaccesstoken-DB657A26-1D37-EB11-A813-000D3A0B97CA.json | 2 +- ...rgethesolution-5004652F-F9B3-EA11-A812-000D3A86AD99.json | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/Add-BuildTagForEachUpdatedSolution.ps1 b/scripts/Add-BuildTagForEachUpdatedSolution.ps1 index 8a25f4b..a83aae5 100644 --- a/scripts/Add-BuildTagForEachUpdatedSolution.ps1 +++ b/scripts/Add-BuildTagForEachUpdatedSolution.ps1 @@ -2,10 +2,10 @@ $resultArray = git show --name-only [System.Collections.ArrayList]$changedSolutions = @() foreach ($_ in $resultArray) { - if ($_.StartsWith("solutions") -and $_.Contains("Extract")) { - $solutionName = $_.Split("/")[1] + if ($_.StartsWith("src/solutions") -and $_.Contains("Extract")) { + $solutionName = $_.Split("/")[2] - if (!$solutionList.Contains($solutionName)) { + if (!$changedSolutions.Contains($solutionName)) { $changedSolutions.Add($solutionName) Write-Host "##vso[build.addbuildtag]$solutionName" } diff --git a/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule.xml b/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule.xml index 2f3ec68..d256418 100644 --- a/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule.xml +++ b/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule.xml @@ -22,8 +22,8 @@ - + diff --git a/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule_managed.xml b/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule_managed.xml index 189f258..63d577a 100644 --- a/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule_managed.xml +++ b/src/solutions/devhub_DevelopmentHub_Develop/Extract/AppModules/devhub_DevelopmentHub/AppModule_managed.xml @@ -16,8 +16,8 @@ - + diff --git a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Other/Solution.xml b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Other/Solution.xml index d840476..ea09375 100644 --- a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Other/Solution.xml +++ b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Other/Solution.xml @@ -1,5 +1,5 @@  - + devhub_DevelopmentHub_Develop @@ -401,7 +401,7 @@ - + diff --git a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Button-Getaccesstoken-DB657A26-1D37-EB11-A813-000D3A0B97CA.json b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Button-Getaccesstoken-DB657A26-1D37-EB11-A813-000D3A0B97CA.json index 93a3bb3..d1f42dc 100644 --- a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Button-Getaccesstoken-DB657A26-1D37-EB11-A813-000D3A0B97CA.json +++ b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Button-Getaccesstoken-DB657A26-1D37-EB11-A813-000D3A0B97CA.json @@ -1 +1 @@ -{"properties":{"connectionReferences":{},"definition":{"$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion":"1.0.0.0","parameters":{"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"manual":{"type":"Request","kind":"Button","inputs":{"schema":{"type":"object","properties":{"text":{"title":"Tenant ID","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"},"text_1":{"title":"Client ID","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"},"text_2":{"title":"Client Secret","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"}},"required":["text","text_1","text_2"]}}}},"actions":{"Get_access_token":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"https://login.microsoftonline.com/@{triggerBody()['text']}/oauth2/token","headers":{"Content-Type":"application/x-www-form-urlencoded"},"body":"client_id=@{triggerBody()['text_1']}&\nclient_secret=@{triggerBody()['text_2']}&\ngrant_type=client_credentials&\nresource=https://org2666ab67.crm11.dynamics.com"}},"Parse_JSON":{"runAfter":{"Get_access_token":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_access_token')","schema":{"type":"object","properties":{"token_type":{"type":"string"},"expires_in":{"type":"string"},"ext_expires_in":{"type":"string"},"expires_on":{"type":"string"},"not_before":{"type":"string"},"resource":{"type":"string"},"access_token":{"type":"string"}}}}},"Respond_to_a_PowerApp_or_flow":{"runAfter":{"Parse_JSON":["Succeeded"]},"type":"Response","kind":"PowerApp","inputs":{"statusCode":200,"body":{"access_token":"@body('Parse_JSON')?['access_token']"},"schema":{"type":"object","properties":{"access_token":{"title":"Access Token","x-ms-dynamically-added":true,"type":"string"}}}}}},"outputs":{}}},"schemaVersion":"1.0.0.0"} \ No newline at end of file +{"properties":{"connectionReferences":{},"definition":{"$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion":"1.0.0.0","parameters":{"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"manual":{"type":"Request","kind":"Button","inputs":{"schema":{"type":"object","properties":{"text":{"title":"Tenant ID","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"},"text_1":{"title":"Client ID","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"},"text_2":{"title":"Client Secret","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"},"text_3":{"title":"Resource","type":"string","x-ms-dynamically-added":true,"description":"Please enter your input","x-ms-content-hint":"TEXT"}},"required":["text","text_1","text_2","text_3"]}}}},"actions":{"Get_access_token":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"https://login.microsoftonline.com/@{triggerBody()['text']}/oauth2/token","headers":{"Content-Type":"application/x-www-form-urlencoded"},"body":"client_id=@{triggerBody()['text_1']}&\nclient_secret=@{triggerBody()['text_2']}&\ngrant_type=client_credentials&\nresource=@{triggerBody()['text_3']}"}},"Parse_JSON":{"runAfter":{"Get_access_token":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_access_token')","schema":{"type":"object","properties":{"token_type":{"type":"string"},"expires_in":{"type":"string"},"ext_expires_in":{"type":"string"},"expires_on":{"type":"string"},"not_before":{"type":"string"},"resource":{"type":"string"},"access_token":{"type":"string"}}}}},"Respond_to_a_PowerApp_or_flow":{"runAfter":{"Parse_JSON":["Succeeded"]},"type":"Response","kind":"PowerApp","inputs":{"statusCode":200,"body":{"access_token":"@body('Parse_JSON')?['access_token']"},"schema":{"type":"object","properties":{"access_token":{"title":"Access Token","x-ms-dynamically-added":true,"type":"string"}}}}}},"outputs":{}}},"schemaVersion":"1.0.0.0"} \ No newline at end of file diff --git a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Whenasolutionmergeisapproved-Mergethesolution-5004652F-F9B3-EA11-A812-000D3A86AD99.json b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Whenasolutionmergeisapproved-Mergethesolution-5004652F-F9B3-EA11-A812-000D3A86AD99.json index 5588979..066ea43 100644 --- a/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Whenasolutionmergeisapproved-Mergethesolution-5004652F-F9B3-EA11-A812-000D3A86AD99.json +++ b/src/solutions/devhub_DevelopmentHub_Develop/Extract/Workflows/Whenasolutionmergeisapproved-Mergethesolution-5004652F-F9B3-EA11-A812-000D3A86AD99.json @@ -1 +1 @@ -{"properties":{"connectionReferences":{"shared_commondataserviceforapps":{"runtimeSource":"embedded","connection":{},"api":{"name":"shared_commondataserviceforapps"}},"shared_approvals":{"runtimeSource":"embedded","connection":{},"api":{"name":"shared_approvals"}}},"definition":{"$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion":"1.0.0.0","parameters":{"$connections":{"defaultValue":{},"type":"Object"},"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"When_a_solution_merge_is_approved":{"type":"OpenApiConnectionWebhook","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"SubscribeWebhookTrigger","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"subscriptionRequest/message":3,"subscriptionRequest/entityname":"devhub_solutionmerge","subscriptionRequest/scope":4,"subscriptionRequest/filteringattributes":"statuscode","subscriptionRequest/filterexpression":"statuscode eq 353400000"},"authentication":"@parameters('$authentication')"},"description":"Using devhub_approvedon rather than statuscode as the flow wasn't triggering with statuscode as a filtering attribute"}},"actions":{"Merge_development_solution":{"actions":{"Get_the_last_approved_solution_merge":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"ListRecords","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","$select":"devhub_name","$filter":"devhub_solutionmergeid ne @{triggerOutputs()?['body/devhub_solutionmergeid']} and (statuscode eq 353400000 or statuscode eq 353400003 or statuscode eq 353400002 or statuscode eq 353400006)","$orderby":"devhub_approvedon desc","$top":1},"authentication":"@parameters('$authentication')"}},"If_another_solution_merge_is_in_progress":{"actions":{"Create_a_note_stating_the_solution_merge_is_queued":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Solution merge queued","item/notetext":"This solution merge has been queued behind '@{outputs('Get_the_last_approved_solution_merge')?['body/value'][0]['devhub_name']}'.","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Cancel_the_flow":{"runAfter":{"Queue_the_solution_merge":["Succeeded"]},"type":"Terminate","inputs":{"runStatus":"Cancelled"}},"Queue_the_solution_merge":{"runAfter":{"Create_a_note_stating_the_solution_merge_is_queued":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformBoundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","actionName":"Microsoft.Dynamics.CRM.devhub_QueueSolutionMerge","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Get_the_last_approved_solution_merge":["Succeeded"]},"expression":{"not":{"equals":["@outputs('Get_the_last_approved_solution_merge')?['body/value']?[0]?['devhub_solutionmergeid']","@null"]}},"type":"If"},"Get_the_target_environment":{"runAfter":{"If_another_solution_merge_is_in_progress":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","$select":"devhub_solutionid,devhub_uniquename","$expand":"devhub_StagingEnvironment($select=devhub_environmentid,devhub_tenantid,devhub_clientid,devhub_clientsecret,devhub_url)"},"authentication":"@parameters('$authentication')"}},"Update_the_solution_merge_status_to_merging":{"runAfter":{"Get_the_target_environment":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400003},"authentication":"@parameters('$authentication')"}},"Get_the_developed_issue":{"runAfter":{"Update_the_solution_merge_status_to_merging":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_issues","recordId":"@outputs('Update_the_solution_merge_status_to_merging')?['body/_devhub_issue_value']","$select":"devhub_developmentsolution,devhub_type"},"authentication":"@parameters('$authentication')"}},"Export_the_development_solution":{"runAfter":{"Get_the_developed_issue":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformUnboundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"actionName":"ExportSolution","item/SolutionName":"@outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']","item/Managed":false,"item/ExportAutoNumberingSettings":false,"item/ExportCalendarSettings":false,"item/ExportCustomizationSettings":false,"item/ExportEmailTrackingSettings":false,"item/ExportGeneralSettings":false,"item/ExportMarketingSettings":false,"item/ExportOutlookSynchronizationSettings":false,"item/ExportRelationshipRoles":false,"item/ExportIsvConfig":false,"item/ExportSales":false,"item/ExportExternalApplications":false},"authentication":"@parameters('$authentication')"}},"Get_access_token_for_staging_environment":{"runAfter":{"Export_the_development_solution":["Succeeded"]},"type":"Workflow","inputs":{"host":{"workflowReferenceName":"db657a26-1d37-eb11-a813-000d3a0b97ca"},"body":{"text":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_tenantid']","text_1":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_clientid']","text_2":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_clientsecret']"}}},"Import_development_solution":{"runAfter":{"Get_access_token_for_staging_environment":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ImportSolution","headers":{"Content-Type":"application/json"},"body":{"CustomizationFile":"@{outputs('Export_the_development_solution')?['body/ExportSolutionFile']}","OverwriteUnmanagedCustomizations":true,"PublishWorkflows":true,"ImportJobId":"@{variables('importJobId')}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Query_import_job_until_done":{"actions":{"Get_import_job":{"runAfter":{},"type":"Http","inputs":{"method":"GET","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/importjobs(@{variables('importJobId')})","authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Parse_import_job_JSON":{"runAfter":{"Get_import_job":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_import_job')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"importcontext":{"type":"string"},"_organizationid_value":{"type":"string"},"startedon":{"type":"string"},"solutionid":{"type":"string"},"progress":{"type":"integer"},"importjobid":{"type":"string"},"data":{"type":"string"},"_createdby_value":{"type":"string"},"operationcontext":{"type":"string"},"modifiedon":{"type":"string"},"solutionname":{"type":"string"},"_modifiedby_value":{"type":"string"},"completedon":{"type":"string"},"createdon":{"type":"string"},"name":{"type":"string"},"_modifiedonbehalfby_value":{},"utcconversiontimezonecode":{},"_createdonbehalfby_value":{},"timezoneruleversionnumber":{}}}}},"Set_importJobProgress":{"runAfter":{"Parse_import_job_JSON":["Succeeded"]},"type":"SetVariable","inputs":{"name":"importJobProgress","value":"@body('Parse_import_job_JSON')?['progress']"}},"If_incomplete":{"actions":{"Delay":{"runAfter":{},"type":"Wait","inputs":{"interval":{"count":1,"unit":"Minute"}}}},"runAfter":{"Set_importJobProgress":["Succeeded"]},"expression":{"less":["@variables('importJobProgress')",100]},"type":"If"}},"runAfter":{"Import_development_solution":["Succeeded"]},"expression":"@equals(variables('importJobProgress'), 100)","limit":{"count":60,"timeout":"PT1H"},"type":"Until"},"If_importing_the_development_solution_failed":{"actions":{"Create_a_note_stating_the_solution_import_failed":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Solution import failed","item/notetext":"The import into the staging environment failed with the following error:\n\n@{xpath(xml(body('Parse_import_job_JSON')?['data']), 'string(/importexportxml/solutionManifests/solutionManifest/result/@errortext)')}","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Fail_the_flow":{"runAfter":{"Update_the_solution_merge_to_failed":["Succeeded"]},"type":"Terminate","inputs":{"runStatus":"Failed","runError":{"message":"The development solution import failed"}}},"Update_the_solution_merge_to_failed":{"runAfter":{"Create_a_note_stating_the_solution_import_failed":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400002},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Query_import_job_until_done":["Succeeded"]},"expression":{"equals":["@xpath(xml(body('Parse_import_job_JSON')?['data']), 'string(/importexportxml/solutionManifests/solutionManifest/result/@result)')","failure"]},"type":"If"},"Get_solutions":{"runAfter":{"If_importing_the_development_solution_failed":["Succeeded"]},"type":"Http","inputs":{"method":"GET","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions?$filter=uniquename eq '@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}' or uniquename eq '@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}'&$select=uniquename&$expand=solution_solutioncomponent($select=objectid,componenttype,rootcomponentbehavior)","authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Parse_solutions_JSON":{"runAfter":{"Get_solutions":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_solutions')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"value":{"type":"array","items":{"type":"object","properties":{"@@odata.etag":{"type":"string"},"uniquename":{"type":"string"},"solutionid":{"type":"string"},"solution_solutioncomponent":{"type":"array"},"solution_solutioncomponent@odata.nextLink":{"type":"string"}},"required":["@@odata.etag","uniquename","solutionid","solution_solutioncomponent","solution_solutioncomponent@odata.nextLink"]}}}}}},"Filter_development_solution":{"runAfter":{"Parse_solutions_JSON":["Succeeded"]},"type":"Query","inputs":{"from":"@body('Parse_solutions_JSON')?['value']","where":"@equals(item()?['uniquename'], outputs('Get_the_developed_issue')?['body/devhub_developmentsolution'])"}},"Filter_target_solution":{"runAfter":{"Set_developmentSolutionComponents":["Succeeded"]},"type":"Query","inputs":{"from":"@body('Parse_solutions_JSON')?['value']","where":"@equals(item()?['uniquename'], outputs('Get_the_target_environment')?['body/devhub_uniquename'])"}},"Apply_to_each_development_solution_component":{"foreach":"@variables('developmentSolutionComponents')","actions":{"Find_target_solution_component_for_same_object_ID":{"runAfter":{},"type":"Query","inputs":{"from":"@variables('targetSolutionComponents')","where":"@equals(item()?['objectid'], items('Apply_to_each_development_solution_component')?['objectid'])"}},"If_matching_target_solution_component":{"actions":{"If_root_component_behavior_should_be_updated":{"actions":{"Update_solution_component":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/UpdateSolutionComponent","headers":{"Content-Type":"application/json"},"body":{"ComponentId":"@{items('Apply_to_each_development_solution_component')?['objectid']}","ComponentType":"@items('Apply_to_each_development_solution_component')?['componenttype']","SolutionUniqueName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}","IncludedComponentSettingsValues":"@if(equals(item()?['rootcomponentbehaviour'], 2), createArray(), null)"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}}},"runAfter":{},"expression":{"and":[{"not":{"equals":["@first(body('Find_target_solution_component_for_same_object_ID'))['rootcomponentbehavior']","@item()?['rootcomponentbehavior']"]}},{"not":{"equals":["@first(body('Find_target_solution_component_for_same_object_ID'))['rootcomponentbehavior']",0]}},{"not":{"equals":["@item()?['rootcomponentbehavior']","@null"]}}]},"type":"If"}},"runAfter":{"Find_target_solution_component_for_same_object_ID":["Succeeded"]},"else":{"actions":{"Add_solution_component":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/AddSolutionComponent","headers":{"Content-Type":"application/json"},"body":{"ComponentId":"@{string(item()?['objectid'])}","ComponentType":"@items('Apply_to_each_development_solution_component')?['componenttype']","SolutionUniqueName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}","AddRequiredComponents":false,"DoNotIncludeSubcomponents":"@if(equals(item()?['rootcomponentbehavior'], 0), false, true)","IncludedComponentSettingsValues":"@if(equals(item()?['rootcomponentbehaviour'], 2), createArray(), null)"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}}}},"expression":{"greater":["@length(body('Find_target_solution_component_for_same_object_ID'))",0]},"type":"If"}},"runAfter":{"Set_targetSolutionComponents":["Succeeded"]},"type":"Foreach"},"Get_the_post-merge_solution_version":{"runAfter":{"Apply_to_each_development_solution_component":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformBoundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","actionName":"Microsoft.Dynamics.CRM.devhub_GetPostMergeSolutionVersion","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']"},"authentication":"@parameters('$authentication')"}},"Update_target_solution_version":{"runAfter":{"Get_the_post-merge_solution_version":["Succeeded"]},"type":"Http","inputs":{"method":"PATCH","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions(@{first(body('Filter_target_solution'))?['solutionid']})","headers":{"Content-Type":"application/json"},"body":{"version":"@{outputs('Get_the_post-merge_solution_version')?['body/MajorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Publish":{"runAfter":{"Update_target_solution_version":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/PublishAllXml","headers":{"Content-Type":"application/json"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"If_there_are_manual_merge_activities":{"actions":{"Update_the_solution_merge_status_to_awaiting_manual_merge":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400006},"authentication":"@parameters('$authentication')"}},"Start_and_wait_for_an_approval":{"runAfter":{"Get_the_solution_merge_creator":["Succeeded"]},"type":"OpenApiConnectionWebhook","inputs":{"host":{"connectionName":"shared_approvals","operationId":"StartAndWaitForAnApproval","apiId":"/providers/Microsoft.PowerApps/apis/shared_approvals"},"parameters":{"approvalType":"CustomResponse","WebhookApprovalCreationInput/responseOptions":["Merged"],"WebhookApprovalCreationInput/title":"Solution merge awaiting manual merge activities - @{triggerOutputs()?['body/devhub_name']}","WebhookApprovalCreationInput/assignedTo":"@outputs('Get_the_solution_merge_creator')?['body/internalemailaddress']","WebhookApprovalCreationInput/enableNotifications":true,"WebhookApprovalCreationInput/enableReassignment":true},"authentication":"@parameters('$authentication')"}},"Get_the_solution_merge_creator":{"runAfter":{"Update_the_solution_merge_status_to_awaiting_manual_merge":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"systemusers","recordId":"@triggerOutputs()?['body/_createdby_value']","$select":"internalemailaddress,personalemailaddress"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Publish":["Succeeded"]},"expression":{"equals":["@triggerOutputs()?['body/devhub_manualmergeactivities']",true]},"type":"If"},"Delete_development_solution":{"runAfter":{"If_there_are_manual_merge_activities":["Succeeded"]},"type":"Http","inputs":{"method":"DELETE","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions(@{first(body('Filter_development_solution'))?['solutionid']})","headers":{"Content-Type":"application/json"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Export_managed_solution":{"runAfter":{"Delete_development_solution":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ExportSolution","headers":{"Content-Type":"application/json"},"body":{"Managed":true,"SolutionName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Parse_export_managed_solution_JSON":{"runAfter":{"Export_managed_solution":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Export_managed_solution')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"ExportSolutionFile":{"type":"string"}}}}},"Export_unmanaged_solution":{"runAfter":{"Parse_export_managed_solution_JSON":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ExportSolution","headers":{"Content-Type":"application/json"},"body":{"Managed":false,"SolutionName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Parse_export_unmanaged_solution_JSON":{"runAfter":{"Export_unmanaged_solution":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Export_unmanaged_solution')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"ExportSolutionFile":{"type":"string"}}}}},"Set_developmentSolutionComponents":{"runAfter":{"Filter_development_solution":["Succeeded"]},"type":"SetVariable","inputs":{"name":"developmentSolutionComponents","value":"@first(body('Filter_development_solution'))['solution_solutioncomponent']"}},"Set_targetSolutionComponents":{"runAfter":{"Filter_target_solution":["Succeeded"]},"type":"SetVariable","inputs":{"name":"targetSolutionComponents","value":"@first(body('Filter_target_solution'))['solution_solutioncomponent']"}}},"runAfter":{"Initialize_targetSolutionComponents":["Succeeded"]},"type":"Scope"},"Initialize_importJobId":{"runAfter":{},"type":"InitializeVariable","inputs":{"variables":[{"name":"importJobId","type":"string","value":"@{guid()}"}]}},"Initialize_importJobProgress":{"runAfter":{"Initialize_importJobId":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"importJobProgress","type":"float","value":0}]}},"Initialize_developmentSolutionComponents":{"runAfter":{"Initialize_importJobProgress":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"developmentSolutionComponents","type":"array"}]}},"Initialize_targetSolutionComponents":{"runAfter":{"Initialize_developmentSolutionComponents":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"targetSolutionComponents","type":"array"}]}},"Set_solution_merge_status_to_'Failed'_(merge_development_solution)":{"runAfter":{"Merge_development_solution":["Failed","TimedOut"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statecode":0,"item/statuscode":353400002},"authentication":"@parameters('$authentication')"}},"If_solution_version_was_created":{"actions":{"Delete_solution_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"DeleteRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/@odata.id']"},"authentication":"@parameters('$authentication')"}},"Set_solution_merge_status_to_'Failed'_(create_new_solution_version)":{"runAfter":{"Delete_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statecode":0,"item/statuscode":353400002},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Create_new_solution_version":["Failed","TimedOut"]},"expression":{"not":{"equals":["@outputs('Create_a_new_solution_version')?['body/@odata.id']","@null"]}},"type":"If"},"Create_new_solution_version":{"actions":{"Create_a_new_solution_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","item/devhub_Solution@odata.bind":"devhub_solutions(@{triggerOutputs()?['body/_devhub_targetsolution_value']})","item/devhub_version":"@{outputs('Get_the_post-merge_solution_version')?['body/MajorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']}"},"authentication":"@parameters('$authentication')"}},"Upload_managed_solution_zip":{"runAfter":{"Create_a_new_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']","fileImageFieldName":"devhub_managedsolutionzip","item":"@base64ToBinary(body('Parse_export_managed_solution_JSON')?['ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}_managed.zip"},"authentication":"@parameters('$authentication')"}},"Upload_unmanaged_zip":{"runAfter":{"Upload_managed_solution_zip":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']","fileImageFieldName":"devhub_unmanagedsolutionzip","item":"@base64ToBinary(body('Parse_export_unmanaged_solution_JSON')?['ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}.zip"},"authentication":"@parameters('$authentication')"}},"If_issue_is_feature":{"actions":{"Update_solution_minor_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","item/devhub_minorversion":"@outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Upload_unmanaged_zip":["Succeeded"]},"else":{"actions":{"Update_solution_patch_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","item/devhub_patchversion":"@outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']"},"authentication":"@parameters('$authentication')"}}}},"expression":{"equals":["@outputs('Get_the_developed_issue')?['body/devhub_type']",353400001]},"type":"If"}},"runAfter":{"Merge_development_solution":["Succeeded"]},"type":"Scope"},"Update_the_solution_merge_to_'Merged'_and_link_solution_version":{"runAfter":{"Create_new_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/devhub_SolutionVersion@odata.bind":"devhub_solutionversions(@{outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']})","item/statecode":1,"item/statuscode":353400001},"authentication":"@parameters('$authentication')"}},"Archive_development_solution_on_solution_merge":{"runAfter":{"Update_the_solution_merge_to_'Merged'_and_link_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","fileImageFieldName":"devhub_developmentsolution","item":"@base64ToBinary(outputs('Export_the_development_solution')?['body/ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}.zip"},"authentication":"@parameters('$authentication')"}},"Get_the_development_solution_by_unique_name":{"runAfter":{"Archive_development_solution_on_solution_merge":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"ListRecords","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"solutions","$select":"solutionid","$filter":"uniquename eq '@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}'","$top":1},"authentication":"@parameters('$authentication')"}},"Delete_the_development_solution":{"runAfter":{"Get_the_development_solution_by_unique_name":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"DeleteRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"solutions","recordId":"@first(outputs('Get_the_development_solution_by_unique_name')?['body/value'])['solutionid']"},"authentication":"@parameters('$authentication')"}},"Create_a_failure_note_on_the_solution_merge_(merge_development_solution)":{"runAfter":{"Set_solution_merge_status_to_'Failed'_(merge_development_solution)":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Failed to merge","item/notetext":"Failed to merge the development solution with the target solution. Please refer to the flow run for more detail. \n\n","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Create_a_failure_note_on_the_solution_merge_(create_new_solution_version)":{"runAfter":{"If_solution_version_was_created":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Failed to create new solution version","item/notetext":"Failed to create a new solution version. Please refer to the flow run for more detail. ","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}}},"outputs":{}}},"schemaVersion":"1.0.0.0"} \ No newline at end of file +{"properties":{"connectionReferences":{"shared_commondataserviceforapps":{"runtimeSource":"embedded","connection":{},"api":{"name":"shared_commondataserviceforapps"}},"shared_approvals":{"runtimeSource":"embedded","connection":{},"api":{"name":"shared_approvals"}}},"definition":{"$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion":"1.0.0.0","parameters":{"$connections":{"defaultValue":{},"type":"Object"},"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"When_a_solution_merge_is_approved":{"type":"OpenApiConnectionWebhook","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"SubscribeWebhookTrigger","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"subscriptionRequest/message":3,"subscriptionRequest/entityname":"devhub_solutionmerge","subscriptionRequest/scope":4,"subscriptionRequest/filteringattributes":"statuscode","subscriptionRequest/filterexpression":"statuscode eq 353400000"},"authentication":"@parameters('$authentication')"},"description":"Using devhub_approvedon rather than statuscode as the flow wasn't triggering with statuscode as a filtering attribute"}},"actions":{"Merge_development_solution":{"actions":{"Get_the_last_approved_solution_merge":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"ListRecords","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","$select":"devhub_name","$filter":"devhub_solutionmergeid ne @{triggerOutputs()?['body/devhub_solutionmergeid']} and (statuscode eq 353400000 or statuscode eq 353400003 or statuscode eq 353400002 or statuscode eq 353400006)","$orderby":"devhub_approvedon desc","$top":1},"authentication":"@parameters('$authentication')"}},"If_another_solution_merge_is_in_progress":{"actions":{"Create_a_note_stating_the_solution_merge_is_queued":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Solution merge queued","item/notetext":"This solution merge has been queued behind '@{outputs('Get_the_last_approved_solution_merge')?['body/value'][0]['devhub_name']}'.","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Cancel_the_flow":{"runAfter":{"Queue_the_solution_merge":["Succeeded"]},"type":"Terminate","inputs":{"runStatus":"Cancelled"}},"Queue_the_solution_merge":{"runAfter":{"Create_a_note_stating_the_solution_merge_is_queued":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformBoundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","actionName":"Microsoft.Dynamics.CRM.devhub_QueueSolutionMerge","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Get_the_last_approved_solution_merge":["Succeeded"]},"expression":{"not":{"equals":["@outputs('Get_the_last_approved_solution_merge')?['body/value']?[0]?['devhub_solutionmergeid']","@null"]}},"type":"If"},"Get_the_target_environment":{"runAfter":{"If_another_solution_merge_is_in_progress":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","$select":"devhub_solutionid,devhub_uniquename","$expand":"devhub_StagingEnvironment($select=devhub_environmentid,devhub_tenantid,devhub_clientid,devhub_clientsecret,devhub_url)"},"authentication":"@parameters('$authentication')"}},"Update_the_solution_merge_status_to_merging":{"runAfter":{"Get_the_target_environment":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400003},"authentication":"@parameters('$authentication')"}},"Get_the_developed_issue":{"runAfter":{"Update_the_solution_merge_status_to_merging":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_issues","recordId":"@outputs('Update_the_solution_merge_status_to_merging')?['body/_devhub_issue_value']","$select":"devhub_developmentsolution,devhub_type"},"authentication":"@parameters('$authentication')"}},"Export_the_development_solution":{"runAfter":{"Get_the_developed_issue":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformUnboundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"actionName":"ExportSolution","item/SolutionName":"@outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']","item/Managed":false,"item/ExportAutoNumberingSettings":false,"item/ExportCalendarSettings":false,"item/ExportCustomizationSettings":false,"item/ExportEmailTrackingSettings":false,"item/ExportGeneralSettings":false,"item/ExportMarketingSettings":false,"item/ExportOutlookSynchronizationSettings":false,"item/ExportRelationshipRoles":false,"item/ExportIsvConfig":false,"item/ExportSales":false,"item/ExportExternalApplications":false},"authentication":"@parameters('$authentication')"}},"Get_access_token_for_staging_environment":{"runAfter":{"Export_the_development_solution":["Succeeded"]},"type":"Workflow","inputs":{"host":{"workflowReferenceName":"db657a26-1d37-eb11-a813-000d3a0b97ca"},"body":{"text":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_tenantid']","text_1":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_clientid']","text_2":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_clientsecret']","text_3":"@outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']"}}},"Import_development_solution":{"runAfter":{"Get_access_token_for_staging_environment":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ImportSolution","headers":{"Content-Type":"application/json"},"body":{"CustomizationFile":"@{outputs('Export_the_development_solution')?['body/ExportSolutionFile']}","OverwriteUnmanagedCustomizations":true,"PublishWorkflows":true,"ImportJobId":"@{variables('importJobId')}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Query_import_job_until_done":{"actions":{"Get_import_job":{"runAfter":{},"type":"Http","inputs":{"method":"GET","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/importjobs(@{variables('importJobId')})","authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Parse_import_job_JSON":{"runAfter":{"Get_import_job":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_import_job')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"importcontext":{"type":"string"},"_organizationid_value":{"type":"string"},"startedon":{"type":"string"},"solutionid":{"type":"string"},"progress":{"type":"number"},"importjobid":{"type":"string"},"data":{"type":"string"},"_createdby_value":{"type":"string"},"operationcontext":{"type":"string"},"modifiedon":{"type":"string"},"solutionname":{"type":"string"},"_modifiedby_value":{"type":"string"},"completedon":{"type":"string"},"createdon":{"type":"string"},"name":{"type":"string"},"_modifiedonbehalfby_value":{},"utcconversiontimezonecode":{},"_createdonbehalfby_value":{},"timezoneruleversionnumber":{}}}}},"Set_importJobProgress":{"runAfter":{"Parse_import_job_JSON":["Succeeded"]},"type":"SetVariable","inputs":{"name":"importJobProgress","value":"@body('Parse_import_job_JSON')?['progress']"}},"If_incomplete":{"actions":{"Delay":{"runAfter":{},"type":"Wait","inputs":{"interval":{"count":1,"unit":"Minute"}}}},"runAfter":{"Set_importJobProgress":["Succeeded"]},"expression":{"less":["@variables('importJobProgress')",100]},"type":"If"}},"runAfter":{"Import_development_solution":["Succeeded","TimedOut","Failed"]},"expression":"@equals(variables('importJobProgress'), 100)","limit":{"count":60,"timeout":"PT1H"},"type":"Until"},"If_importing_the_development_solution_failed":{"actions":{"Create_a_note_stating_the_solution_import_failed":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Solution import failed","item/notetext":"The import into the staging environment failed with the following error:\n\n@{xpath(xml(body('Parse_import_job_JSON')?['data']), 'string(/importexportxml/solutionManifests/solutionManifest/result/@errortext)')}","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Fail_the_flow":{"runAfter":{"Update_the_solution_merge_to_failed":["Succeeded"]},"type":"Terminate","inputs":{"runStatus":"Failed","runError":{"message":"The development solution import failed"}}},"Update_the_solution_merge_to_failed":{"runAfter":{"Create_a_note_stating_the_solution_import_failed":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400002},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Query_import_job_until_done":["Succeeded"]},"expression":{"equals":["@xpath(xml(body('Parse_import_job_JSON')?['data']), 'string(/importexportxml/solutionManifests/solutionManifest/result/@result)')","failure"]},"type":"If"},"Get_solutions":{"runAfter":{"If_importing_the_development_solution_failed":["Succeeded"]},"type":"Http","inputs":{"method":"GET","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions?$filter=uniquename eq '@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}' or uniquename eq '@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}'&$select=uniquename&$expand=solution_solutioncomponent($select=objectid,componenttype,rootcomponentbehavior)","authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"},"retryPolicy":{"type":"none"}}},"Parse_solutions_JSON":{"runAfter":{"Get_solutions":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_solutions')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"value":{"type":"array","items":{"type":"object","properties":{"@@odata.etag":{"type":"string"},"uniquename":{"type":"string"},"solutionid":{"type":"string"},"solution_solutioncomponent":{"type":"array"},"solution_solutioncomponent@odata.nextLink":{"type":"string"}},"required":["@@odata.etag","uniquename","solutionid","solution_solutioncomponent","solution_solutioncomponent@odata.nextLink"]}}}}}},"Filter_development_solution":{"runAfter":{"Parse_solutions_JSON":["Succeeded"]},"type":"Query","inputs":{"from":"@body('Parse_solutions_JSON')?['value']","where":"@equals(item()?['uniquename'], outputs('Get_the_developed_issue')?['body/devhub_developmentsolution'])"}},"Filter_target_solution":{"runAfter":{"Set_developmentSolutionComponents":["Succeeded"]},"type":"Query","inputs":{"from":"@body('Parse_solutions_JSON')?['value']","where":"@equals(item()?['uniquename'], outputs('Get_the_target_environment')?['body/devhub_uniquename'])"}},"Apply_to_each_development_solution_component":{"foreach":"@variables('developmentSolutionComponents')","actions":{"Find_target_solution_component_for_same_object_ID":{"runAfter":{},"type":"Query","inputs":{"from":"@variables('targetSolutionComponents')","where":"@equals(item()?['objectid'], items('Apply_to_each_development_solution_component')?['objectid'])"}},"If_matching_target_solution_component":{"actions":{"If_root_component_behavior_should_be_updated":{"actions":{"Update_solution_component":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/UpdateSolutionComponent","headers":{"Content-Type":"application/json"},"body":{"ComponentId":"@{items('Apply_to_each_development_solution_component')?['objectid']}","ComponentType":"@items('Apply_to_each_development_solution_component')?['componenttype']","SolutionUniqueName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}","IncludedComponentSettingsValues":"@if(equals(item()?['rootcomponentbehaviour'], 2), createArray(), null)"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}}},"runAfter":{},"expression":{"and":[{"not":{"equals":["@first(body('Find_target_solution_component_for_same_object_ID'))['rootcomponentbehavior']","@item()?['rootcomponentbehavior']"]}},{"not":{"equals":["@first(body('Find_target_solution_component_for_same_object_ID'))['rootcomponentbehavior']",0]}},{"not":{"equals":["@item()?['rootcomponentbehavior']","@null"]}}]},"type":"If"}},"runAfter":{"Find_target_solution_component_for_same_object_ID":["Succeeded"]},"else":{"actions":{"Add_solution_component":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/AddSolutionComponent","headers":{"Content-Type":"application/json"},"body":{"ComponentId":"@{string(item()?['objectid'])}","ComponentType":"@items('Apply_to_each_development_solution_component')?['componenttype']","SolutionUniqueName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}","AddRequiredComponents":false,"DoNotIncludeSubcomponents":"@if(equals(item()?['rootcomponentbehavior'], 0), false, true)","IncludedComponentSettingsValues":"@if(equals(item()?['rootcomponentbehaviour'], 2), createArray(), null)"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}}}},"expression":{"greater":["@length(body('Find_target_solution_component_for_same_object_ID'))",0]},"type":"If"}},"runAfter":{"Set_targetSolutionComponents":["Succeeded"]},"type":"Foreach"},"Get_the_post-merge_solution_version":{"runAfter":{"Apply_to_each_development_solution_component":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"PerformBoundAction","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","actionName":"Microsoft.Dynamics.CRM.devhub_GetPostMergeSolutionVersion","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']"},"authentication":"@parameters('$authentication')"}},"Update_target_solution_version":{"runAfter":{"Get_the_post-merge_solution_version":["Succeeded"]},"type":"Http","inputs":{"method":"PATCH","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions(@{first(body('Filter_target_solution'))?['solutionid']})","headers":{"Content-Type":"application/json"},"body":{"version":"@{outputs('Get_the_post-merge_solution_version')?['body/MajorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Publish":{"runAfter":{"Update_target_solution_version":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/PublishAllXml","headers":{"Content-Type":"application/json"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"If_there_are_manual_merge_activities":{"actions":{"Update_the_solution_merge_status_to_awaiting_manual_merge":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statuscode":353400006},"authentication":"@parameters('$authentication')"}},"Start_and_wait_for_an_approval":{"runAfter":{"Get_the_solution_merge_creator":["Succeeded"]},"type":"OpenApiConnectionWebhook","inputs":{"host":{"connectionName":"shared_approvals","operationId":"StartAndWaitForAnApproval","apiId":"/providers/Microsoft.PowerApps/apis/shared_approvals"},"parameters":{"approvalType":"CustomResponse","WebhookApprovalCreationInput/responseOptions":["Merged"],"WebhookApprovalCreationInput/title":"Solution merge awaiting manual merge activities - @{triggerOutputs()?['body/devhub_name']}","WebhookApprovalCreationInput/assignedTo":"@outputs('Get_the_solution_merge_creator')?['body/internalemailaddress']","WebhookApprovalCreationInput/enableNotifications":true,"WebhookApprovalCreationInput/enableReassignment":true},"authentication":"@parameters('$authentication')"}},"Get_the_solution_merge_creator":{"runAfter":{"Update_the_solution_merge_status_to_awaiting_manual_merge":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"GetItem","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"systemusers","recordId":"@triggerOutputs()?['body/_createdby_value']","$select":"internalemailaddress,personalemailaddress"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Publish":["Succeeded"]},"expression":{"equals":["@triggerOutputs()?['body/devhub_manualmergeactivities']",true]},"type":"If"},"Delete_development_solution":{"runAfter":{"If_there_are_manual_merge_activities":["Succeeded"]},"type":"Http","inputs":{"method":"DELETE","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/solutions(@{first(body('Filter_development_solution'))?['solutionid']})","headers":{"Content-Type":"application/json"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Export_managed_solution":{"runAfter":{"Delete_development_solution":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ExportSolution","headers":{"Content-Type":"application/json"},"body":{"Managed":true,"SolutionName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Parse_export_managed_solution_JSON":{"runAfter":{"Export_managed_solution":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Export_managed_solution')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"ExportSolutionFile":{"type":"string"}}}}},"Export_unmanaged_solution":{"runAfter":{"Parse_export_managed_solution_JSON":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"@{outputs('Get_the_target_environment')?['body/devhub_stagingenvironment/devhub_url']}/api/data/v9.1/ExportSolution","headers":{"Content-Type":"application/json"},"body":{"Managed":false,"SolutionName":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}"},"authentication":{"type":"Raw","value":"Bearer @{outputs('Get_access_token_for_staging_environment')?['Body']?['access_token']}"}}},"Parse_export_unmanaged_solution_JSON":{"runAfter":{"Export_unmanaged_solution":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Export_unmanaged_solution')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"ExportSolutionFile":{"type":"string"}}}}},"Set_developmentSolutionComponents":{"runAfter":{"Filter_development_solution":["Succeeded"]},"type":"SetVariable","inputs":{"name":"developmentSolutionComponents","value":"@first(body('Filter_development_solution'))['solution_solutioncomponent']"}},"Set_targetSolutionComponents":{"runAfter":{"Filter_target_solution":["Succeeded"]},"type":"SetVariable","inputs":{"name":"targetSolutionComponents","value":"@first(body('Filter_target_solution'))['solution_solutioncomponent']"}}},"runAfter":{"Initialize_targetSolutionComponents":["Succeeded"]},"type":"Scope"},"Initialize_importJobId":{"runAfter":{},"type":"InitializeVariable","inputs":{"variables":[{"name":"importJobId","type":"string","value":"@{guid()}"}]}},"Initialize_importJobProgress":{"runAfter":{"Initialize_importJobId":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"importJobProgress","type":"float","value":0}]}},"Initialize_developmentSolutionComponents":{"runAfter":{"Initialize_importJobProgress":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"developmentSolutionComponents","type":"array"}]}},"Initialize_targetSolutionComponents":{"runAfter":{"Initialize_developmentSolutionComponents":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"targetSolutionComponents","type":"array"}]}},"Set_solution_merge_status_to_'Failed'_(merge_development_solution)":{"runAfter":{"Merge_development_solution":["Failed","TimedOut"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statecode":0,"item/statuscode":353400002},"authentication":"@parameters('$authentication')"}},"If_solution_version_was_created":{"actions":{"Delete_solution_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"DeleteRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/@odata.id']"},"authentication":"@parameters('$authentication')"}},"Set_solution_merge_status_to_'Failed'_(create_new_solution_version)":{"runAfter":{"Delete_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/statecode":0,"item/statuscode":353400002},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Create_new_solution_version":["Failed","TimedOut"]},"expression":{"not":{"equals":["@outputs('Create_a_new_solution_version')?['body/@odata.id']","@null"]}},"type":"If"},"Create_new_solution_version":{"actions":{"Create_a_new_solution_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","item/devhub_Solution@odata.bind":"devhub_solutions(@{triggerOutputs()?['body/_devhub_targetsolution_value']})","item/devhub_version":"@{outputs('Get_the_post-merge_solution_version')?['body/MajorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']}.@{outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']}"},"authentication":"@parameters('$authentication')"}},"Upload_managed_solution_zip":{"runAfter":{"Create_a_new_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']","fileImageFieldName":"devhub_managedsolutionzip","item":"@base64ToBinary(body('Parse_export_managed_solution_JSON')?['ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}_managed.zip"},"authentication":"@parameters('$authentication')"}},"Upload_unmanaged_zip":{"runAfter":{"Upload_managed_solution_zip":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionversions","recordId":"@outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']","fileImageFieldName":"devhub_unmanagedsolutionzip","item":"@base64ToBinary(body('Parse_export_unmanaged_solution_JSON')?['ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_target_environment')?['body/devhub_uniquename']}.zip"},"authentication":"@parameters('$authentication')"}},"If_issue_is_feature":{"actions":{"Update_solution_minor_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","item/devhub_minorversion":"@outputs('Get_the_post-merge_solution_version')?['body/MinorVersion']"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Upload_unmanaged_zip":["Succeeded"]},"else":{"actions":{"Update_solution_patch_version":{"runAfter":{},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutions","recordId":"@triggerOutputs()?['body/_devhub_targetsolution_value']","item/devhub_patchversion":"@outputs('Get_the_post-merge_solution_version')?['body/PatchVersion']"},"authentication":"@parameters('$authentication')"}}}},"expression":{"equals":["@outputs('Get_the_developed_issue')?['body/devhub_type']",353400001]},"type":"If"}},"runAfter":{"Merge_development_solution":["Succeeded"]},"type":"Scope"},"Update_the_solution_merge_to_'Merged'_and_link_solution_version":{"runAfter":{"Create_new_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","item/devhub_SolutionVersion@odata.bind":"devhub_solutionversions(@{outputs('Create_a_new_solution_version')?['body/devhub_solutionversionid']})","item/statecode":1,"item/statuscode":353400001},"authentication":"@parameters('$authentication')"}},"Archive_development_solution_on_solution_merge":{"runAfter":{"Update_the_solution_merge_to_'Merged'_and_link_solution_version":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"UpdateEntityFileImageFieldContent","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"devhub_solutionmerges","recordId":"@triggerOutputs()?['body/devhub_solutionmergeid']","fileImageFieldName":"devhub_developmentsolution","item":"@base64ToBinary(outputs('Export_the_development_solution')?['body/ExportSolutionFile'])","x-ms-file-name":"@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}.zip"},"authentication":"@parameters('$authentication')"}},"Get_the_development_solution_by_unique_name":{"runAfter":{"Archive_development_solution_on_solution_merge":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"ListRecords","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"solutions","$select":"solutionid","$filter":"uniquename eq '@{outputs('Get_the_developed_issue')?['body/devhub_developmentsolution']}'","$top":1},"authentication":"@parameters('$authentication')"}},"Delete_the_development_solution":{"runAfter":{"Get_the_development_solution_by_unique_name":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"DeleteRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"solutions","recordId":"@first(outputs('Get_the_development_solution_by_unique_name')?['body/value'])['solutionid']"},"authentication":"@parameters('$authentication')"}},"Create_a_failure_note_on_the_solution_merge_(merge_development_solution)":{"runAfter":{"Set_solution_merge_status_to_'Failed'_(merge_development_solution)":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Failed to merge","item/notetext":"Failed to merge the development solution with the target solution. Please refer to the flow run for more detail. \n\n","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}},"Create_a_failure_note_on_the_solution_merge_(create_new_solution_version)":{"runAfter":{"If_solution_version_was_created":["Succeeded"]},"type":"OpenApiConnection","inputs":{"host":{"connectionName":"shared_commondataserviceforapps","operationId":"CreateRecord","apiId":"/providers/Microsoft.PowerApps/apis/shared_commondataserviceforapps"},"parameters":{"entityName":"annotations","item/subject":"Failed to create new solution version","item/notetext":"Failed to create a new solution version. Please refer to the flow run for more detail. ","item/objectid_devhub_solutionmerge@odata.bind":"devhub_solutionmerges(@{triggerOutputs()?['body/devhub_solutionmergeid']})"},"authentication":"@parameters('$authentication')"}}},"outputs":{}}},"schemaVersion":"1.0.0.0"} \ No newline at end of file