Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,8 @@ codeunit 6610 "FS Int. Table Subscriber"
IgnoreArchievedServiceOrdersOnQueryPostFilterIgnoreRecord(SourceRecordRef, IgnoreRecord);
Database::"FS Work Order":
IgnoreArchievedCRMWorkOrdersOnQueryPostFilterIgnoreRecord(SourceRecordRef, IgnoreRecord);
Database::"Service Item":
IgnoreServiceItemsByConvertToCustomerAssetFlag(SourceRecordRef, IgnoreRecord);
end;

if FSConnectionSetup.IsEnabled() then
Expand Down Expand Up @@ -2683,6 +2685,37 @@ codeunit 6610 "FS Int. Table Subscriber"
IgnoreRecord := true;
end;

internal procedure IgnoreServiceItemsByConvertToCustomerAssetFlag(SourceRecordRef: RecordRef; var IgnoreRecord: Boolean)
var
FSConnectionSetup: Record "FS Connection Setup";
ServiceItem: Record "Service Item";
Item: Record Item;
CRMIntegrationRecord: Record "CRM Integration Record";
CRMProduct: Record "CRM Product";
begin
if not FSConnectionSetup.IsEnabled() then
exit;

if IgnoreRecord then
exit;

SourceRecordRef.SetTable(ServiceItem);
if ServiceItem."Item No." = '' then
exit;

if not Item.Get(ServiceItem."Item No.") then
exit;

if not CRMIntegrationRecord.FindByRecordID(Item.RecordId) then
exit;

if not CRMProduct.Get(CRMIntegrationRecord."CRM ID") then
exit;

if not CRMProduct.ConvertToCustomerAsset then
IgnoreRecord := true;
end;

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Integration Table Synch.", 'OnAfterInitSynchJob', '', true, true)]
local procedure LogTelemetryOnAfterInitSynchJob(ConnectionType: TableConnectionType; IntegrationTableID: Integer)
var
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ tableextension 6617 "FS CRM Product" extends "CRM Product"
OptionMembers = Inventory,Service,"Non-Inventory";
DataClassification = SystemMetadata;
}
field(12001; ConvertToCustomerAsset; Boolean)
{
Caption = 'Convert to Customer Asset';
Description = 'Indicates whether the product should generate a customer asset.';
ExternalName = 'msdyn_converttocustomerasset';
ExternalType = 'Boolean';
DataClassification = SystemMetadata;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ codeunit 139205 "FS Integration Test Library"
FSIntTableSubscriber.IgnoreArchievedCRMWorkOrdersOnQueryPostFilterIgnoreRecord(SourceRecordRef, IgnoreRecord);
end;

procedure IgnoreServiceItemsByConvertToCustomerAssetFlag(SourceRecordRef: RecordRef; var IgnoreRecord: Boolean)
var
FSIntTableSubscriber: Codeunit "FS Int. Table Subscriber";
begin
FSIntTableSubscriber.IgnoreServiceItemsByConvertToCustomerAssetFlag(SourceRecordRef, IgnoreRecord);
end;

procedure MarkArchivedServiceOrder(ServiceHeader: Record "Service Header")
var
FSIntTableSubscriber: Codeunit "FS Int. Table Subscriber";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using Microsoft.Purchases.Vendor;
using Microsoft.Sales.Customer;
using Microsoft.Service.Archive;
using Microsoft.Service.Document;
using Microsoft.Service.Item;
using Microsoft.Service.Setup;
using Microsoft.Service.Test;
using Microsoft.TestLibraries.DynamicsFieldService;
Expand Down Expand Up @@ -1572,6 +1573,112 @@ codeunit 139204 "FS Integration Test"
Assert.AreEqual(0, WorkOrderProduct.QuantityConsumed, 'Quantity Consumed should not be written into Work Order record for Posting Preview action.');
end;

[Test]
procedure IgnoreServiceItemWhenConvertToCustomerAssetIsFalse()
var
Item: Record Item;
TempServiceItem: Record "Service Item" temporary;
CRMProduct: Record "CRM Product";
CRMIntegrationRecord: Record "CRM Integration Record";
RecordRef: RecordRef;
IgnoreRecord: Boolean;
ProductId: Guid;
begin
// [FEATURE] [Service Item Mapping]
// [SCENARIO] Service Item is skipped when linked CRM Product has Convert to Customer Asset = No.
Initialize();
InitSetup(true, '');

Item.Get(CreateItem());
TempServiceItem."Item No." := Item."No.";
RecordRef.GetTable(TempServiceItem);

ProductId := CreateGuid();
CRMProduct.ProductId := ProductId;
CRMProduct.ConvertToCustomerAsset := false;
CRMProduct.Insert(false);

CRMIntegrationRecord.CoupleCRMIDToRecordID(ProductId, Item.RecordId());

FSIntegrationTestLibrary.IgnoreServiceItemsByConvertToCustomerAssetFlag(RecordRef, IgnoreRecord);

Assert.IsTrue(IgnoreRecord, 'Service Item should be ignored when Convert to Customer Asset is false.');
end;

[Test]
procedure DoNotIgnoreServiceItemWhenConvertToCustomerAssetIsTrue()
var
Item: Record Item;
TempServiceItem: Record "Service Item" temporary;
CRMProduct: Record "CRM Product";
CRMIntegrationRecord: Record "CRM Integration Record";
RecordRef: RecordRef;
IgnoreRecord: Boolean;
ProductId: Guid;
begin
// [FEATURE] [Service Item Mapping]
// [SCENARIO] Service Item is not skipped when linked CRM Product has Convert to Customer Asset = Yes.
Initialize();
InitSetup(true, '');

Item.Get(CreateItem());
TempServiceItem."Item No." := Item."No.";
RecordRef.GetTable(TempServiceItem);

ProductId := CreateGuid();
CRMProduct.ProductId := ProductId;
CRMProduct.ConvertToCustomerAsset := true;
CRMProduct.Insert(false);

CRMIntegrationRecord.CoupleCRMIDToRecordID(ProductId, Item.RecordId());

FSIntegrationTestLibrary.IgnoreServiceItemsByConvertToCustomerAssetFlag(RecordRef, IgnoreRecord);

Assert.IsFalse(IgnoreRecord, 'Service Item should not be ignored when Convert to Customer Asset is true.');
end;

[Test]
procedure DoNotIgnoreServiceItemWhenItemNoIsBlank()
var
TempServiceItem: Record "Service Item" temporary;
RecordRef: RecordRef;
IgnoreRecord: Boolean;
begin
// [FEATURE] [Service Item Mapping]
// [SCENARIO] Service Item with blank Item No. is not skipped by this filter.
Initialize();
InitSetup(true, '');

TempServiceItem."Item No." := '';
RecordRef.GetTable(TempServiceItem);

FSIntegrationTestLibrary.IgnoreServiceItemsByConvertToCustomerAssetFlag(RecordRef, IgnoreRecord);

Assert.IsFalse(IgnoreRecord, 'Service Item with blank Item No. should not be ignored by this filter.');
end;

[Test]
procedure DoNotIgnoreServiceItemWhenItemIsNotCoupled()
var
Item: Record Item;
TempServiceItem: Record "Service Item" temporary;
RecordRef: RecordRef;
IgnoreRecord: Boolean;
begin
// [FEATURE] [Service Item Mapping]
// [SCENARIO] Service Item with uncoupled Item is not skipped by this filter.
Initialize();
InitSetup(true, '');

Item.Get(CreateItem());
TempServiceItem."Item No." := Item."No.";
RecordRef.GetTable(TempServiceItem);

FSIntegrationTestLibrary.IgnoreServiceItemsByConvertToCustomerAssetFlag(RecordRef, IgnoreRecord);

Assert.IsFalse(IgnoreRecord, 'Service Item with uncoupled Item should not be ignored by this filter.');
end;

local procedure Initialize()
var
AssistedSetupTestLibrary: Codeunit "Assisted Setup Test Library";
Expand Down
Loading