Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

Posted on by 35

Hi,

I'm having a hard time following the 'Customizing an Integration with Microsoft Dataverse' guide on the Docs website and I'm currently on the step where you gotta use the Codeunit CRM Setup Defaults (ID 5334) to subscribe on the OnAddEntityTableMapping event in order to enable deep linking between coupled Business Central records and Microsoft Dataverse records.

[EventSubscriber(ObjectType::CodeunitCodeunit::"CRM Setup Defaults", 'OnAddEntityTableMapping''', true, true)]
    local procedure HandleOnAddEntityTableMapping(var TempNameValueBuffer: Record "Name/Value Buffer" temporary)
    var
        CRMSetupDefaults: Codeunit "CRM Setup Defaults";
    begin
        CRMSetupDefaults.AddEntityTableMapping('Order Type'DATABASE::"LGX SNV Order Type", TempNameValueBuffer);
        CRMSetupDefaults.AddEntityTableMapping('Order Type'DATABASE::"CRM new_ordertype", TempNameValueBuffer);
    end;

But when I try to use the procedure for adding the entity, it gets highlited in red stating that the codeunit does not contains a definition for the procedure I'm trying to use.

'Codeunit "CRM Setup Defaults"' does not contain a definition for 'AddEntityTableMapping'AL(AL0132)

Is there any way to fix this? I just checked the codeunit and the procedure is there. I'm wondering if it could be something permission-related.

I would really appreciate any help with this. Thanks

  • IronBark Profile Picture
    IronBark 5 on at
    RE: Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

    Hi there,

    I has this problem as well (I'm on the latest BC v18.3).

    Add this code to your codeunit:
        local procedure AddEntityTableMapping(CRMEntityTypeName: Text; TableID: Integervar TempNameValueBuffer: Record "Name/Value Buffer" temporary)

        //Replicates the same local procedure in Codeunit "CRM Setup Defaults"
        begin
            //OnBeforeAddEntityTableMapping(CRMEntityTypeName, TableID, TempNameValueBuffer); //Note, if you subscribe to this you'll need to cater for this as well.
            TempNameValueBuffer.Init();
            TempNameValueBuffer.ID := TempNameValueBuffer.Count + 1;
            TempNameValueBuffer.Name := CopyStr(CRMEntityTypeName, 1, MaxStrLen(TempNameValueBuffer.Name));
            TempNameValueBuffer.Value := Format(TableID);
            TempNameValueBuffer.Insert();
        end;
    and replace:
     CRMSetupDefaults.AddEntityTableMapping('Order Type', DATABASE::"LGX SNV Order Type", TempNameValueBuffer);
    CRMSetupDefaults.AddEntityTableMapping('Order Type', DATABASE::"CRM new_ordertype", TempNameValueBuffer);
    with:
     AddEntityTableMapping('Order Type', DATABASE::"LGX SNV Order Type", TempNameValueBuffer);
    AddEntityTableMapping('Order Type', DATABASE::"CRM new_ordertype", TempNameValueBuffer);
  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

    I checked with current version and I could not see that function. Maybe the symbols you have are old and referencing the new version.

  • Gelatina Profile Picture
    Gelatina 35 on at
    RE: Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

    I'm using Saas, but I am actually able to see the procedure in the codeunit, nonetheless it is being marked as if the codeunit doesn't exist in the current context.

    Doesn't matter if I import it on an event subscriber, on a variable on a page, however I try to use it is being marked regardless of it's existance.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

    I don't see that function in the codeunit either, which version of BC are using ? OnPrem or Saas?

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Codeunit::"CRM Setup Defaults" fields doesn't exist in current context

    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.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developerss

    I will open this up to the community in case they have something to add.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans