Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Check Field validation

Posted on by 255

Hey,

we have a xmlport that imports data and create sales header and line records. The only problem we have is that when during the import if some error happens, we need to catch it.  Is it possible to check if "Field.validate" return true/false?, and based on the return value, something else should happens. 

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Check Field validation

    Hi,

    You can use a fieldref and codeunit 8613 like below:

    CLEAR(ConfigTryValidate);
    ConfigTryValidate.SetValidateParameters(MyFldRef, MyValue);
    IF NOT ConfigTryValidate.RUN THEN
      LogMyError(GETLASTERRORTEXT);


  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Check Field validation

    You need to use COMMIT after every transaction to use Codeunit. RUN. You need to commit any write transactions before usin that.

  • lynix_x Profile Picture
    lynix_x 255 on at
    RE: Check Field validation

    Thanks Tharanga,

    i tried that, but now i'm getting following error:

    The following C/AL functions can be used only to a limited degree during write transactions (because one or more tables will be locked).

    CodeUnit.Run() is allowed in write transactions only if the return value is not used. For example, 'OK := CodeUnit.Run()' is not allowed.

    Use the COMMIT function to save the changes before this call, or structure the code differently.

  • Suggested answer
    TharangaC Profile Picture
    TharangaC 23,116 on at

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans