[FS] Prevent duplicate Field Service customer assets during item synchronization - #11094
[FS] Prevent duplicate Field Service customer assets during item synchronization#11094tomasevicst wants to merge 2 commits into
Conversation
|
The removed IgnoreServiceItem* tests, and the new ItemSynchronizationDisablesCustomerAssetConversion test, both call the helper procedure directly rather than exercising the actual dispatch path. Critically, the new 'Item-CRM Product' case added to OnBeforeTransferFieldData (which does DestinationRecordRef.SetTable(CRMProduct) / DisableCustomerAssetConversion(...) / DestinationRecordRef.GetTable(CRMProduct)) is never exercised by any test — no test drives an Item-to-CRMProduct transfer through the RecordRef dispatch to confirm the case is reached and the record is written back correctly. Add an integration-style test that triggers the Item-CRM Product transfer path (e.g. via the subscriber's OnBeforeTransferFieldData or a full sync call) and asserts the resulting CRM Product has ConvertToCustomerAsset = false. Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6 |
…ronization logic for service items
| FSIntTableSubscriber.IgnoreArchievedCRMWorkOrdersOnQueryPostFilterIgnoreRecord(SourceRecordRef, IgnoreRecord); | ||
| end; | ||
|
|
||
| [Obsolete('Service items are always synchronized to Field Service customer assets. The Convert to Customer Asset flag is no longer used for filtering', '30.0')] |
There was a problem hiding this comment.
FS Integration Test Library is a public library codeunit, but the touched public procedure IgnoreServiceItemsByConvertToCustomerAssetFlag has no XML documentation. Even though the procedure is now obsolete, it remains part of the library surface until removal, so add a /// <summary> and /// <param> documentation block that explains the deprecation context and the parameters.
Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6
|
|
||
| FSIntegrationTestLibrary.IgnoreServiceItemsByConvertToCustomerAssetFlag(RecordRef, IgnoreRecord); | ||
| // [WHEN] The Field Service product is prepared for synchronization from an item. | ||
| FSIntegrationTestLibrary.DisableCustomerAssetConversion(CRMProduct, AdditionalFieldsWereModified); |
There was a problem hiding this comment.
ItemSynchronizationDisablesCustomerAssetConversion claims to verify item synchronization, but it calls FSIntegrationTestLibrary.DisableCustomerAssetConversion directly. That only proves the extracted helper flips the fields; the test would still pass if FS Int. Table Subscriber.OnAfterHandleCustomIntegrationTableMapping (OnAfterTransferRecordFields) stopped dispatching the Item-CRM Product path. Exercise the actual synchronization callback or another item-to-product synchronization entry point so the test covers the wiring introduced by this change.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6
| FSIntTableSubscriber.IgnoreArchievedCRMWorkOrdersOnQueryPostFilterIgnoreRecord(SourceRecordRef, IgnoreRecord); | ||
| end; | ||
|
|
||
| [Obsolete('Service items are always synchronized to Field Service customer assets. The Convert to Customer Asset flag is no longer used for filtering', '30.0')] |
There was a problem hiding this comment.
IgnoreServiceItemsByConvertToCustomerAssetFlag is now marked obsolete, but the obsoletion reason only explains why the old filter is gone; it does not tell consumers what to use instead. BCQuality's obsoletion guidance expects obsolete methods to include actionable migration guidance in the reason. Update the reason to point callers to DisableCustomerAssetConversion() (or the new always-false item/product mapping) so the deprecation has a clear replacement path.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
[Obsolete('Use DisableCustomerAssetConversion() or rely on the item-product mapping, because service items are always synchronized to Field Service customer assets and the Convert to Customer Asset filter is no longer used.', '30.0')]Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6
What & why
Business Central and Field Service could both create a Customer Asset for the same item, resulting in duplicates when a Work Order was completed.
This change keeps Business Central as the source for Customer Asset creation by:
Linked work
Fixes AB#649195
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility
Risk is low and limited to coupled Field Service Products. Their Convert to Customer Asset value is overwritten to No during Item synchronization, preventing native Field Service asset creation.
Uncoupled Field Service Products are unaffected. No schema or public API changes are introduced. Existing configurations are covered by runtime enforcement, while reset or newly created mappings receive the constant outbound mapping.