Skip to content

[FS] Prevent duplicate Field Service customer assets during item synchronization - #11094

Open
tomasevicst wants to merge 2 commits into
mainfrom
bugs/649195_FS_Duplicate_Field_Service_Customer_Asset_Created
Open

[FS] Prevent duplicate Field Service customer assets during item synchronization#11094
tomasevicst wants to merge 2 commits into
mainfrom
bugs/649195_FS_Duplicate_Field_Service_Customer_Asset_Created

Conversation

@tomasevicst

@tomasevicst tomasevicst commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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:

  • Setting Convert to Customer Asset to No for Products synchronized from BC Items.
  • Adding the rule to the default Item-Product mapping.
  • Removing the Product flag as a filter for Service Item synchronization.
  • Adding tests for runtime enforcement and mapping configuration.

Linked work

Fixes AB#649195

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

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.

@tomasevicst
tomasevicst requested a review from a team September 5, 2026 09:44
@tomasevicst
tomasevicst requested a review from a team as a code owner September 5, 2026 09:45
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration labels Sep 5, 2026
@github-actions github-actions Bot added this to the Version 30.0 milestone Sep 5, 2026
@tomasevicst tomasevicst added the Team: SCM GitHub request for SCM area label Sep 5, 2026
@github-actions github-actions Bot removed the Team: SCM GitHub request for SCM area label Sep 5, 2026
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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

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')]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Style}$

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Testing}$

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')]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$\textbf{🟡\ Medium\ Severity\ —\ Upgrade}$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1 Ownership: Needs Review Ownership is Other, low confidence, or needs manual correction Team: Other GitHub request for other area than SCM, Finance or Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant