-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Purge-Failures-Caused-by-Custom-Plugin.md #5374
Open
s3mishra
wants to merge
3
commits into
MicrosoftDocs:main
Choose a base branch
from
s3mishra:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
powerapps-docs/developer/data-platform/Purge-Failures-Caused-by-Custom-Plugin.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# How to Identify Purge Failures Caused by a Custom Plugin | ||
|
||
## When to Start the Investigation | ||
Start investigating if the "Retention Failed" count increases within the pending delete state. | ||
|
||
## Steps to Follow: | ||
|
||
### 1. Verify if the Failure is Due to a Custom Plugin | ||
Confirm whether the failure is triggered by a custom plugin that executes on the "Delete" message for the specific entities. Check the `RetentionFailureDetail` table to see if the `OperationID` matches `RetentionOperationId`, and the `OperationType` equals `30` (indicating Purge). | ||
|
||
``` | ||
<OrgUrl>/api/data/v9.0/retentionfailuredetails?$filter=operationid%20eq%20%27<RetentionOperationID>%27%20and%20operation%20eq%2030 | ||
``` | ||
|
||
![image.png](/.attachments/image-d4cfc4a8-f295-4083-8128-30e533cc6721.png) | ||
|
||
We can also review the Plugin Trace Logs to identify the failure point. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing image |
||
![image2.PNG](/.attachments/image2-d68cc343-d8d4-4ea7-9409-bd09ac08daea.PNG) | ||
### 2. Bypassing the Validation for Deletes Triggered by Retention | ||
If you want to bypass validation for deletes initiated during retention, modify your plugin logic as shown below: | ||
|
||
```csharp | ||
class SampleDeletePlugin : IPlugin | ||
{ | ||
public void Execute(IServiceProvider serviceProvider) | ||
{ | ||
if (IsDeleteDueToRetention(serviceProvider)) | ||
{ | ||
// Insert logic to handle deletes triggered by retention | ||
} | ||
else | ||
{ | ||
// Insert logic to handle regular deletes not related to retention | ||
} | ||
} | ||
|
||
private bool IsDeleteDueToRetention(IServiceProvider serviceProvider) | ||
{ | ||
IPluginExecutionContext currentContext = (IPluginExecutionContext) | ||
serviceProvider.GetService(typeof(IPluginExecutionContext)); | ||
while (currentContext != null) | ||
{ | ||
if (currentContext.InputParameters.TryGetValue<bool>("DeleteInvokedByRetention", out var isDeleteByRetention) && isDeleteByRetention) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
``` | ||
|
||
### 3. Apply Similar Validation for Retain Messages | ||
To apply similar validation for retention, you can create a plugin on the "Retain" message. Follow the same approach as described above for handling retention-based logic, but ensure the logic is suited to the "Retain" message. | ||
|
||
### 4. Additional Resources | ||
- [Reference to Long-term data retention | ||
](https://learn.microsoft.com/en-us/power-apps/developer/data-platform/long-term-retention?tabs=sdk#custom-logic-while-retention-executes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing image. Add image to the ./media folder and update the image path in the markdown reference.