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 :
Small and medium business | Business Central, N...
Suggested Answer

Variant Business Central

(0) ShareShare
ReportReport
Posted on by 10

Anyone can share code about VARIANT how to write variant code.

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    The question is honestly not too much clear to me.

    As an example, the following example determines whether a C/AL variant contains a record variable. The GET function gets customer number 10000 from the Customer table. The record is stored in the MyRecord variable. The MyRecord variable is assigned to the variant variable that is named MyVariant. The ISRECORD function determines whether the variant contains a Record variable and stores the return value in the varResult variable. In this case, the variant contains a Record variable so Yes is returned and displayed in a message box. 

    MyRecord.GET('10000');
    MyVariant := MyRecord;
    varResult := MyVariant.ISRECORD;
    MESSAGE(Text000,MyVariant,varResult);
    varResult := MyVariant.ISCODE;
    MESSAGE(Text001,MyVariant,varResult);

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,917

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,161 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,025 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans