Announcements
I have an integration between CRM and Business Central (both online) and it's working great for data types that are the same in both systems. I would like to sync a lookup field (guid) from CRM to Business Central by passing the name in the lookup field (custom mapping) to a text field in BC. I have the following in a table extension:
Hi Jazzy,
You can achieve the above requirement by making the fieldclass property to FlowField and default a calcformula which then uses your GUID field for lookup.
Please see the below image.
field(21; OwningBusinessUnit; GUID) { ExternalName = 'owningbusinessunit'; ExternalType = 'Lookup'; ExternalAccess = Read; Description = 'Unique identifier for the business unit that owns the record'; Caption = 'Owning Business Unit'; TableRelation = "CRM BusinessUnit".BusinessUnitId; } field(24; OwningBusinessUnitName; Text[160]) { FieldClass = FlowField; CalcFormula = lookup("CRM BusinessUnit".Name where(BusinessUnitId = field(OwningBusinessUnit))); ExternalName = 'owningbusinessunitname'; ExternalType = 'String'; ExternalAccess = Read; }
I am able to do this for a variety of fields, but when i map a lookup from CRM it brings the GUID. I would like to get the name in the lookup and insert into a custom text field BC. Not sure how to do this or if there is a better way.
Hi,
You have to use the OnAfterResetCustomerAccountMapping event with codeunit "CDS Setup Defaults" and define the fields there whichever you want to transfer into BC central Table.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"CDS Setup Defaults", 'OnAfterResetCustomerAccountMapping', '', true, true)]
local procedure HandleOnAfterResetCustomerAccountMapping(IntegrationTableMappingName: Code[20])
var
CDSAccount: Record "CRM Account";
CustomerRec: Record Customer;
IntegrationFieldMapping: Record "Integration Field Mapping";
begin
//CDSAccountID for Customer
InsertIntegrationFieldMapping(IntegrationTableMappingName, CustomerRec.FieldNo("NXN CDS Account ID"), CDSAccount.FieldNo(AccountId), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
InsertIntegrationFieldMapping(IntegrationTableMappingName, CustomerRec.FieldNo("No."), CDSAccount.FieldNo(ceda_BC), IntegrationFieldMapping.Direction::Bidirectional, '', true, false);
end;
|
Hello,
We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
I will open this up to the community in case they have something to add.
Thanks.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156