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 AX (Archived)

Macro to assign null value to variable

(0) ShareShare
ReportReport
Posted on by 6

I remember seeing a single macro to assign null value for all datatypes. Can you anyone give me that macro name?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Such a thing doesn't make sense. If you want to assign null to reference types, simply do it; you don't need anything special.

    But you can't do it with "all datatypes", because null isn't a valid value for primitive data types. For instance, you can't assign null to int; there you can only use its default value (0). If this is what you mean, use nullValue(), nullValueBaseType() or nullValueFromType().

  • NoobDaxCoder Profile Picture
    6 on at

    int num = 10;

    real r = 1.1;

    str   s = "my name is vinodh";

    //assigning null standard way

    num = 0;

    s = "";

    //instead, what im asking, any silver bullet macro to assign null for all //variables

    num = [tag:Macro];

    s = [tag:Macro];

  • Verified answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Neither 0 and "" is null. These are default primitive values (not null) for given primitive data types.

    I already gave you the solution for your actual requirement (assigning the default value for any type).

    You're wrong in thinking that a macro would do the job (unless the macro actual contains code like what I mentioned). Stop wasting time looking for macro that doesn't exist and use the methods that do exist.

  • NoobDaxCoder Profile Picture
    6 on at

    Thanks Martin.

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 AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans