[Shopify] Do not block shop disable, shop delete and company delete if webhook cannot be deleted in Shopify #6371
+41
−5
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.
Problem
When disabling a Shopify shop or deleting a shop/company, if the webhook subscription cannot be deleted in Shopify (e.g., due to invalid API credentials, network issues, or the store being disconnected), the operation would fail with an error like:
This blocked users from disabling or deleting shops even when the Shopify store was already disconnected or inaccessible.
Root Cause
The
DeleteWebhookSubscriptionfunction was being called directly, which throws an error if the Shopify API call fails. Additionally, even when using a[TryFunction]wrapper, there were two issues:TryFunction return value not used: In AL, if a TryFunction's return value isn't consumed, it behaves like a regular method and errors are still raised to the user.
Database writes inside TryFunction: The
ExecuteGraphQLfunction writes to the log table, which is not allowed inside a TryFunction when called from certain contexts (like page triggers).Solution
Created a new wrapper codeunit
"Shpfy Delete Webhook Subs."(ID 30458) that uses theCodeunit.Run()pattern instead of[TryFunction]. This pattern:falseon failure)Updated
TryDeleteWebhookSubscriptionto use this codeunit pattern and return aBooleanresult.Updated callers in
ShpfyWebhooksMgtto properly consume the return value withif ... then;syntax.Work Item(s)
AB#619586