web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

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

Validate Country/Region Code error

(0) ShareShare
ReportReport
Posted on by 25

Hi,

i have written a code, which auto assign dimension value Customer."Country/Region Code" := DefaultDimension."Customer Country".

I have issue, that if i change Country/Region Code i got error, that in DefaultDimension already exist record assigned to this Customer No.

So how i can write code, which does if record already exist in the table, then modify, if not then create new one.

Thansk for help.

I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    89,835 Super User 2025 Season 2 on at
    RE: Validate Country/Region Code error

    Hi, I answered a similar question once and hoped to give you some hints.

       

    Thanks.

    ZHU

  • Suggested answer
    Amit Baru Profile Picture
    3,035 on at
    RE: Validate Country/Region Code error

    hi,

    pls send code.

    regards

    Amit Sharma

    www.erpconsultors.com

    www.linkedin.com/.../

  • Mai lah Profile Picture
    25 on at
    RE: Validate Country/Region Code error

    Unlucky it doesnt work :/

    My code which i tried to work with:

    DefDim.Reset;

    DefDim.Setrange(No., DefDim.No);

    DefDim.Setrange(Dimension Code, Dimension.Code);

    if DefDim.Findset then begin

    here modify if get,

    end else,

    here insert if not get.

    I doesn't get error, but it wont assign either.

  • Suggested answer
    Nitin Verma Profile Picture
    21,595 Moderator on at
    RE: Validate Country/Region Code error

    Hi, Please try below

    customer.get("CustomerNo.");

    Customer."Country/Region Code" := DefaultDimension."Customer Country";

    if customer.modify then;

  • Mai lah Profile Picture
    25 on at
    RE: Validate Country/Region Code error

    Any help?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,899 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,444

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,304

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans