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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

IF condition how to write code for Empty option for comparing

(0) ShareShare
ReportReport
Posted on by

IF condition how to write code for Empty option for comparing

i declared type,no,description,unit of measure fields..

for type in option string ..empty means only space comma..like this ,Item,Resource,Fixed Asset

when select the fields type and select No Field it automatically update description field and when select next time same row with other type it should be automatically clear that fields..

i wrote Clear function in Description ,it is clearing but when i executing iam getting error

IF (Type = Type::Item) THEN BEGIN
Ite.GET(No) ;
No:=Ite."No.";
Description := Ite.Description;
END;
IF (Type = Type::"Fixed Asset") THEN BEGIN
Fixed.GET(No) ;
No:=Fixed."No.";
Description := Fixed.Description;
END
ELSE
Reso.GET(No);
Description := Reso.Name;

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    60,999 Super User 2025 Season 2 on at

    what is the error message?

  • Community Member Profile Picture
    on at

    now i wrote this code now it is not showing error but it is cleared when select the Type Item And Select No ,It automatically Taking Description Field But The Selected Item Cleared .  

    I wrote this code in No On Validate Trigger

    IF Type = Type::Item THEN BEGIN

      Ite.GET(No) ;

      Description := Ite.Description;

    END;

    IF Type = Type::"Fixed Asset" THEN BEGIN

      Fixed.GET(No) ;

     Description := Fixed.Description;

    END;

    IF Type=Type::Resource THEN BEGIN

     Reso.GET(No);

     Description := Reso.Name;

    END

    ELSE

    Type:=Type::" ";

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,284 Super User 2025 Season 2 on at

    Because you are not properly using the IF and ELSE tag, the end result will always be either Resource or blank.

    Use CASE instead.

    CASE Type OF BEGIN

      Type::Item :

        BEGIN

           //write code here

        END;

      Type::Resource :

        BEGIN

           //write code here

        END;

      Type::"Fixed Asset" :

        BEGIN

           //write code here

        END;

      ELSE :

        BEGIN

           //write code here

        END;

    END;

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans