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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Insert values using Macros

(0) ShareShare
ReportReport
Posted on by

Hi people,

What I am trying to do in making an insert using values from a method in my class, but I have some problems with the parameters. The macro that I have done is something like this.

#LOCALMACRO.InsertGroupValues

%1.clear();

%1.ItemId = %2;

%1.insert()

#ENDMACRO

public void InsertMethod()

{

Table1  table1;

#InsertGroupValues(table1, "00001")

}

And, in the class method I send the table I want to insert in. The problem is, when I declare the macro, it shows me a syntax error, that means it is not possible to send the table as a parm and insert values in, or I have an error that I haven't seen.

Thank you.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi Kevin Sanchez,

    you missing ";" after %1.insert() in your macro.

  • Community Member Profile Picture
    on at

    Thanks, I haven't seen it.

  • Martin Dráb Profile Picture
    239,385 Most Valuable Professional on at

    But why would you ever use code like this? It's very difficult to debug; the fact that you weren't able to find your bug is a proof.

  • Community Member Profile Picture
    on at

    I want to use it because I will insert values in three different tables, but every table has the same fields, so if I have to insert in one of them, according to a condition that I have in the method, it will send as a parm the table of that specific case.

  • Verified answer
    Martin Dráb Profile Picture
    239,385 Most Valuable Professional on at

    Your requirement can be implemented without abusing macros.

    Probably the best option is using a table map. Map all three tables to the map and write code against the map.

    YourTableMap tableMap = ... // Assign your table buffer here
    tableMap.clear();
    tableMap.ItemId = itemId;
    tableMap.insert();
  • Community Member Profile Picture
    on at

    Thanks my friend, that's another good way to do that, I'll use it in my project.

    Thank you.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans