Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending CRM integration for BC OnCloud e.g. new entity mappings, customizing existing mappings #3844

Open
SteveKrisjanovsD365 opened this issue Sep 25, 2018 · 5 comments
Labels
enhancement This is an enhancement suggestion to existing functionality

Comments

@SteveKrisjanovsD365
Copy link

I have an on-prem client (currently on NAV2009 R2) who is interested in migrating to Business Central OnCloud. Furthermore, I discovered they're interested in integrating with Dynamics 365 Sales for ERP/CRM integration.

I delved into NAV's CRM customization capabilities for another client last year (NAV2016 on-prem) and customizing it was not easy to do: the on-prem NAV way is a hodgebodge of powershell scripts (e.g. the New-NAVCRMTable cmdlet to create/update entity mapping tables), customizing codeunit 5150 Integration Management, etc.

I get the sneaky suspicion that none of this is possible with BC OnCloud and clients have to settle with the CRM integration capabilities that ship with Business Central and nothing else (i.e. cannot map new fields to existing integration tables, cannot create new integration tables). Also, cannot extend codeunits (which is needed when mapping brand new entities). Secondly, New-NAVCRMTable generates text objects with special properties unique to CRM integration.

Is the txt2AL tool even capable of transforming ,txt object with these unique CRM properties? If I created a delta on an existing integration table object, could I even transform it into an AL file for use in an extension?

I couldn't find any sufficient BC documentation on customizing this stuff.

@StanislawStempin
Copy link

@tmeyhoff had a session on this topic at Directions NA. Perhaps he can share more details here as well.

@SteveKrisjanovsD365
Copy link
Author

@StanislawStempin thank you for the update. Looking forward to hearing his input on this!

@yuranshrestha
Copy link

Any Updates on this query? We would like to extend codeunit 5349 Auto Create Sales Order.
image

@srenders
Copy link

You might also want to have a look at this issue: https://www.yammer.com/dynamicsnavdev/#/Threads/show?threadId=1207545665

@charlespockert
Copy link

charlespockert commented Jan 29, 2019

We've managed to get around some of this with one of our clients by hooking certain integration events

This isn't exactly using the base CRM integration to do the sync but shoe-horning certain data into/out of CRM fields using code.

The reason we do this is the client in question has customised a lot of CRM tables and we cannot extend them as this is unsupported. Instead we created a separate view of the customised CRM table containing just the fields we need (and a GUID field for the record PK in CRM).

During the customisation event we take the current record's GUID and re-fetch it using our custom table. This results in BC pulling the custom fields we need and we use that object to populate, for example, a customer record.

Code looks something like this (edited some of the object names for clarity):

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Integration Rec. Synch. Invoke", 'OnAfterInsertRecord', '', true, true)]
    local procedure CRMSyncOnAfterInsertRecord(IntegrationTableMapping: Record "Integration Table Mapping"; SourceRecordRef: RecordRef; var DestinationRecordRef: RecordRef)
    begin
        case DestinationRecordRef.Number() of
            DATABASE::Customer:
                begin
                   // Handle any special field synching
                   AfterInsertCustomerFieldHandling(SourceRecordRef, DestinationRecordRef);
               end;
        end;
    end;

   local procedure AfterInsertCustomerFieldHandling(Source: RecordRef; var Dest: RecordRef)
    var
        Customer: Record Customer;
        CrmAccount: Record "CRM Account";
        CustomCrmAccount: Record "Custom CRM Account Table";
        CrmCountry: Record "Custom CRM Country Table";
        CreditController: Record "CRM Systemuser";
    begin
        if Source.Number() = DATABASE::"CRM Account" then begin
            Dest.SetTable(Customer);
            Source.SetTable(CrmAccount);

            // Get our custom field view to validate some additional fields
            CustomCrmAccount.Get(CrmAccount.AccountId);

            // CC
            if CreditController.Get(CustomCrmAccount."Credit Controller") then begin
                Customer.Validate("Credit Controller", COPYSTR(CreditController.FullName, 1, 250));
            end;

            // Get iso country code
            CrmCountry.Get(CustomCrmAccount."HQ Country");
            Customer.Validate("Country/Region Code", CopyStr(CrmCountry."ISO Country Code", 1, 10));

            Customer.Modify();

            Dest.GetTable(Customer);
        end;
    end;

Obviously this is only on record pull and not push - you'd need to add events for push (by checking for the sync direction on source/dest).

It's not very flexible compared to the mappings - I've considered using field mappings to do this but since you can't extend CRM tables this wouldn't work unless we re-created the whole Account table and added all the custom fields to it - it seems like you can programatically modify the mappings in the CRM integration tables, there's just no access via the user interface (it's all read-only).

Really we need the right events in the right place.

I suppose you could wrap a mini-framework around this for managing the additional fields to sync, I've just not done it here for time reasons.

Might be something I do in future if we end up doing some more CRM implementations that have customisation.

@atoader atoader added enhancement This is an enhancement suggestion to existing functionality and removed question labels Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement suggestion to existing functionality
Projects
None yet
Development

No branches or pull requests

6 participants