Skip to content

Commit ec7dee9

Browse files
author
Matt Wilkinson
committed
Use Get-CrmRecords to allow nolock fetching of status - sync import locks up the rest of the system
1 parent 101f9e0 commit ec7dee9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Microsoft.Xrm.Data.PowerShell/Microsoft.Xrm.Data.PowerShell.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,8 @@ function Import-CrmSolution{
21662166

21672167
#check the import job for success/fail/inProgress
21682168
try{
2169-
$import = Get-CrmRecord -conn $conn -EntityLogicalName importjob -Id $importId -Fields solutionname,data,completedon,startedon,progress
2169+
$records = (Get-CrmRecords -conn $conn -EntityLogicalName importjob -FilterAttribute importjobid -FilterOperator eq -FilterValue $importId -Fields data,completedon,startedon,progress).CrmRecords
2170+
$import = if ($records.Count -gt 0) { $records[0] } else { $null }
21702171
} catch {
21712172
if($transientFailureCount > 5){
21722173
Write-Error "Import Job status check FAILED 5 times this could be due to a bug where the service returns a 401. Throwing lastException:";
@@ -2175,8 +2176,7 @@ function Import-CrmSolution{
21752176
Write-Verbose "Import Job status check FAILED this could be due to a bug where the service returns a 401. We'll allow up to 5 failures before aborting.";
21762177
$transientFailureCount++;
21772178
}
2178-
#Option to use Get-CrmRecords so we can force a no-lock to prevent hangs in the retrieve
2179-
#$import = (Get-CrmRecords -conn $conn -EntityLogicalName importjob -FilterAttribute importjobid -FilterOperator eq -FilterValue $importId -Fields data,completedon,startedon,progress).CrmRecords[0]
2179+
21802180
$importManifest = ([xml]($import).data).importexportxml.solutionManifests.solutionManifest
21812181
$ProcPercent = [double](Coalesce $import.progress "0")
21822182

0 commit comments

Comments
 (0)