Dynamics AX

Tales From The Script: Update Dynamics AX Data with X++ Scripts

True, your Dynamics AX developer has a role to play in the technical aspects of the ERP. For instance, you may be relying on him to create scripts for accomplishing various tasks.

However, if you are a thorough AX user, it may be beneficial to have some basic knowledge on coding scripts. This is especially important if you regularly deal with large masses of data.  By large, we are referring to significant data, perhaps 5,000 or more records.

Dynamics AX

While you can always use Excel to sort out large data, the software’s performance significantly drops as the size of the data increases. For instance, if you have over 100,000 records to sort out, Excel is likely to “hang” and not produce the output you are anticipating.

To manage large masses of data, coding and running a script will make your work fast. This blog source was written by Murray Fife @murrayfife.

Here is an example on how you can easily code a script to manage large data, even without having to call your developer.

Example on How to Code and Run X++ Script

Let’s say that you want to update the Calculation Group of your recently shipped inventory, perhaps because you forgot to load it through DIEF. Here is how you can use X++ script:

  1. i) The first step is to create the script. To do this, click CTRL+D to open up the AOT.
  2. ii) Next, open the Projects explorer by clicking CTRL+SHIFT+P.

iii) Right-mouse-click the Projects folder to reveal a New sub-menu. Click Project from the sub-menu to create a new project.

  1. iv) Name the new project you have created. For your benefit, give it a descriptive name.
  2. v) Next, open the newly-created project by right-mouse-clicking it and selecting Open. The project will be displayed.
  3. vi) Navigate to the header and right-mouse-click to reveal a menu. Select New on the revealed menu and choose the Job

vii) Now, create a variable that points to the table you want to update. In this example, our table is InventTable and the variable is item. Combining these two, we have the following code:

InventTable item;

viii) The next step is to create a loop that will step through every record. To do  this, type:

while select forUpdate item
{
}

  1. ix) Now add your code to find out if there is a record in the table to be updated.  The resulting code will look like this:

if (item)
{
}

  1. x) The final step is to add your code to update the record:

ttsBegin;
item.BOMCalcGroupId = “DEFAULT”;
item.update();
ttscommit;

  1. xi) At this point, your code will look like this:

static void Job11(Args _args)
{
InventTable item;
while select forUpdate item
{
if (item)
{
ttsBegin;
item.BOMCalcGroupId = “DEFAULT”;
item.update();
ttscommit;
}
}
}

xii) The final step is to run the code. To start, click the green play button on the menu bar.  The script will run and update all  the records for you.

And this is how you can easily update your AX data with X++ script.





50 replies
  1. Penelope Maletta
    Penelope Maletta says:

    I just want to mention I am newbie to blogging and really loved this web site. More than likely I’m want to bookmark your blog . You certainly come with terrific articles. Thanks a bunch for revealing your webpage.

  2. where to buy viagra in san francisco
    where to buy viagra in san francisco says:

    After research a few of the post on your website currently, as well as I truly like your means of blogging. I bookmarked it to my book marking web site list as well as will certainly be inspecting back quickly. Pls have a look at my internet site too and let me know what you assume.

  3. you can look here
    you can look here says:

    This is the right blog for any person that wishes to find out about this topic. You understand so much its nearly hard to say with you (not that I actually would want?HaHa). You certainly put a new spin on a topic thats been covered for years. Wonderful stuff, simply great!

  4. cbd isolate for sale kilo
    cbd isolate for sale kilo says:

    Youre so amazing! I don’t intend Ive check out anything like this prior to. So great to discover somebody with some initial ideas on this subject. realy thanks for starting this up. this website is something that is required on the web, a person with a little creativity. helpful job for bringing something brand-new to the internet!

  5. cbd vape e-juice for sale
    cbd vape e-juice for sale says:

    Good post. I discover something much more tough on different blogs day-to-day. It will certainly always be promoting to check out material from various other authors and also exercise a little something from their shop. I?d favor to use some with the material on my blog whether you don?t mind. Natually I?ll provide you a web link on your internet blog. Many thanks for sharing.

  6. John Deere Repair Manuals
    John Deere Repair Manuals says:

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several e-mails with the same comment. Is there any way you can remove me from that service? Appreciate it!

  7. can dogs have cbd capsules
    can dogs have cbd capsules says:

    A remarkable share, I just provided this onto a coworker that was doing a little evaluation on this. And he actually acquired me morning meal due to the fact that I discovered it for him. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the moment to discuss this, I really feel strongly about it as well as like learning more on this topic. Preferably, as you become knowledge, would certainly you mind upgrading your blog site with more details? It is highly helpful for me. Huge thumb up for this blog post!

  8. cbd oil for dogs ellevet
    cbd oil for dogs ellevet says:

    I was really delighted to discover this web-site. I wished to many thanks for your time for this wonderful read!! I certainly delighting in every little bit of it and I have you bookmarked to have a look at brand-new stuff you post.

  9. cbd oil benefits
    cbd oil benefits says:

    Place on with this write-up, I truly assume this internet site needs far more factor to consider. I?ll possibly be once more to review a lot more, many thanks for that info.

  10. try what she says
    try what she says says:

    I found your blog site on google as well as check a few of your very early articles. Continue to maintain the great run. I simply additional up your RSS feed to my MSN Information Visitor. Looking for onward to reading more from you in the future!?

  11. check these guys out
    check these guys out says:

    I am often to blogging and also i truly value your material. The short article has actually peaks my interest. I am mosting likely to bookmark your website and maintain checking for new info.

  12. Charlie Klancnik
    Charlie Klancnik says:

    Can I just state what an alleviation to locate someone who really understands what theyre speaking about on the internet. You absolutely understand exactly how to bring a concern to light and also make it crucial. Even more people require to read this and comprehend this side of the story. I angle believe youre not more preferred due to the fact that you certainly have the gift.

  13. this article
    this article says:

    There are certainly a great deal of details like that to take into account. That is a wonderful indicate raise. I offer the thoughts over as basic inspiration but clearly there are inquiries like the one you raise where the most vital thing will certainly be working in sincere good faith. I don?t understand if ideal practices have arised around points like that, yet I make certain that your job is clearly identified as an up for grabs. Both boys as well as women feel the impact of just a moment?s enjoyment, for the rest of their lives.

  14. advice
    advice says:

    Hello! I just would like to offer a substantial thumbs up for the excellent details you have right here on this post. I will be returning to your blog site for even more soon.

  15. great post to read
    great post to read says:

    I am typically to blogging and i truly appreciate your web content. The short article has truly peaks my rate of interest. I am going to bookmark your website and also maintain checking for brand-new details.

  16. Read More Here
    Read More Here says:

    I was extremely happy to locate this web-site. I wished to thanks for your time for this remarkable read!! I certainly appreciating every little of it as well as I have you bookmarked to take a look at brand-new things you post.

  17. official source
    official source says:

    The next time I review a blog site, I really hope that it does not dissatisfy me as much as this. I mean, I know it was my selection to check out, yet I really thought youd have something intriguing to claim. All I hear is a lot of whining concerning something that you can fix if you werent also active looking for interest.

  18. reference
    reference says:

    The following time I read a blog site, I hope that it does not dissatisfy me as long as this set. I mean, I know it was my option to review, however I in fact believed youd have something fascinating to state. All I hear is a lot of yawping about something that you can take care of if you werent as well busy trying to find focus.

  19. next
    next says:

    I?m amazed, I have to say. Actually hardly ever do I come across a blog that?s both instructional and also entertaining, and also let me inform you, you have actually hit the nail on the head. Your concept is exceptional; the concern is something that inadequate people are speaking wisely around. I am extremely satisfied that I stumbled across this in my search for something connecting to this.

  20. love it
    love it says:

    Can I just state what an alleviation to find a person who actually recognizes what theyre talking about on the net. You certainly know just how to bring an issue to light as well as make it important. Even more people require to read this as well as understand this side of the tale. I cant think youre not a lot more popular due to the fact that you certainly have the present.

  21. Find Out More
    Find Out More says:

    When I initially commented I clicked the -Notify me when brand-new remarks are included- checkbox and also now each time a remark is included I obtain four emails with the exact same comment. Is there any way you can remove me from that solution? Thanks!

  22. can texas residents purchase cbd online legally
    can texas residents purchase cbd online legally says:

    Can I just claim what a relief to locate a person that in fact understands what theyre speaking about on the net. You absolutely know just how to bring a concern to light as well as make it vital. More people require to read this as well as recognize this side of the story. I cant think youre not extra prominent due to the fact that you certainly have the gift.

  23. dr drew opinion on cbd edibles
    dr drew opinion on cbd edibles says:

    The next time I review a blog site, I really hope that it does not dissatisfy me as much as this one. I imply, I know it was my selection to check out, yet I really believed youd have something fascinating to claim. All I listen to is a bunch of yawping regarding something that you could deal with if you werent also hectic searching for interest.

  24. web hosting companies
    web hosting companies says:

    We’re a group of volunteers and opening a new scheme in our community.
    Your web site offered us with valuable information to work on. You have done an impressive
    job and our entire community will be grateful to you.

  25. Mariano Bednar
    Mariano Bednar says:

    An outstanding share, I just offered this onto a coworker that was doing a little analysis on this. And he as a matter of fact acquired me morning meal since I located it for him. smile. So let me reword that: Thnx for the reward! However yeah Thnkx for spending the time to review this, I really feel highly about it as well as enjoy finding out more on this topic. When possible, as you come to be know-how, would certainly you mind updating your blog site with more information? It is very useful for me. Huge thumb up for this article!

  26. Aurora Ozaine
    Aurora Ozaine says:

    Can I just state what an alleviation to locate somebody who in fact recognizes what theyre discussing on the net. You definitely understand exactly how to bring a concern to light and make it essential. Even more people require to read this and recognize this side of the story. I angle believe youre not much more prominent since you definitely have the present.

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *