web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Bulk record deletion m...
Power Apps
Unanswered

Bulk record deletion migration from one environment to another

(0) ShareShare
ReportReport
Posted on by 1,710

Hello,

I created some bulk deletion jobs in my source environment and I would like to move them to production.

I did some research and saw that those jobs were not solution-aware.

Is there any XRMToolbox that migrates those workflows to avoid creating them again manually?

Any help is greatly appreciated.

Best regards,

Julien

I have the same question (0)
  • Ram Prakash Duraisamy Profile Picture
    5,593 Super User 2025 Season 2 on at

    Hi @Julien2 

     

    I didn't tried it but Give a Try in XRM Tool Box Workflow Elements Manager Export it

    and then import it in Import Bulk Deletion Jobs by changing the connection.

     

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Follow me on Twitter : @rampprakashd
    Blog : https://microsoftcrmtechie.blogspot.com

  • EBMRay Profile Picture
    1,710 on at

    Hi @rampprakash ,

     

    Could you please share the link to this tool as I couldn't find it on XRMToolbox?

     

    Thank you!

  • a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Julien,

    This might not work but have you tried using the Configuration Migration Tool?

  • Verified answer
    Linn Zaw Win Profile Picture
    2,996 on at

    @Julien2 

    We use a PowerShell script in the pipeline to deploy the bulk deletion job. I am planning to write up a detailed blog post about it but if you cannot wait for it, here's a glimpse of it.

    You may add the checking of the bulkDeletionJobName in the FetchXML filter but the script that I wrote is for multiple jobs. So, the checking is done outside of the query.

    try { 
     Write-Output "Fetching existing active recurring bulk deletion jobs from environment..."
    
     $fetchQuery = "<fetch>
     <entity name='asyncoperation'>
     <attribute name='name' />
     <attribute name='statuscode' />
     <filter>
     <condition attribute='statuscode' operator='eq' value='10' />
     </filter>
     <link-entity name='bulkdeleteoperation' from='asyncoperationid' to='asyncoperationid' alias='bulkdeleteoperation'>
     <attribute name='bulkdeleteoperationid' />
     <attribute name='isrecurring' />
     <filter>
     <condition attribute='isrecurring' operator='eq' value='1' />
     </filter>
     </link-entity>
     </entity>
     </fetch>"
     $existingBulkDeletionJobs = Get-CrmRecordsByFetch -Fetch $fetchQuery -conn $connection
    
     Write-Output "Existing Bulk Deletion Jobs"
     Write-Output "====================================================="
     $existingBulkDeletionJobs.CrmRecords | ForEach-Object {
     Write-Output "- $($_.name)"
     }
    
     Write-Output "Checking the bulk deletion job is already existing..."
    	$_bulkDeletionJobName = "Bulk Deletion - Test Records - Status = Skipped or Successful"
    	$_exists = $existingBulkDeletionJobs.CrmRecords | Where-Object { $_.name -eq $_bulkDeletionJobName }
    
    	if ($_exists) {
    		Write-Output "Skipping $($_bulkDeletionJobName) as it is already created"
    	}
    	else {
    		Write-Output "Creating bulk deletion job - $($_bulkDeletionJobName)..."
    
    		$query = New-Object Microsoft.Xrm.Sdk.Query.QueryExpression('lzw_test')
    		$query.Criteria.AddCondition('statuscode', [Microsoft.Xrm.Sdk.Query.ConditionOperator]::In, @(3,4))
    		$query.Criteria.AddCondition('createdon', [Microsoft.Xrm.Sdk.Query.ConditionOperator]::OlderThanXDays, 28)
    		Write-Output "New QueryExpression initialised. - $($query.GetType())"
    		
    		[Microsoft.Xrm.Sdk.Query.QueryExpression[]]$querySet = @($query)
    		Write-Output "QuerySet initialised. - $($querySet.GetType())"
    
    		$nextSunday = (Get-Date -Hour 3 -Minute 0 -Second 0).AddDays(7-((Get-Date).DayOfWeek.value__))
    		Invoke-CrmAction -conn $connection -Name 'BulkDelete' -Parameters @{
    			QuerySet = $querySet;
    			JobName = $_bulkDeletionJobName;
    			SendEmailNotification = $false;
    			ToRecipients = [System.Guid[]]@();
    			CCRecipients = [System.Guid[]]@();
    			RecurrencePattern = "FREQ=DAILY;INTERVAL=7";
    			StartDateTime = $nextSunday;
    			}
    	}
    
     Write-Output "Bulk deletion jobs creation completed."
    }
    finally {
     $connection.Dispose()
    }

     

    If there is no pipeline to run a PowerShell script in the project, you may create an instant cloud flow which does the same thing and it needs to be run manually as a post deployment step after the solution import.

    1. Dataverse List Rows step for System Jobs (asyncoperation) with the FetchXML from the script above

    2. If the result does not contain the bulkDeletionJobName that you want to create, call Perform an unbound action step to create a Bulk Deletion Job.

    Note: ToRecipients and CCRecipients are empty array [] because it is a required parameter.

    LinnZawWin_1-1694738202023.png

     

     

     

     

  • EBMRay Profile Picture
    1,710 on at

    Hi @a33ik ,

    I did not I will give it a try.

     

    @LinnZawWin 

    Thank you so much for sharing the below it is very helpful, I will check both options and I am always inspired by your blog posts.

     

    Have a nice weekend!

  • MED85 Profile Picture
    2 on at

    Hi @Julien2 ,
    Have you been looking for a solution for migrating bulk deletion jobs from one environment to another on Power platform or Dynamics CRM?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard