Solved

Dynamics AX 2009 - Programming Example

Posted on 2009-04-06
3
1,045 Views
Last Modified: 2012-05-11
Dear Experts,

In AX 2009 can someone please assist me with the following code example:

Table1
-------------
Id
Description
BeginDate
EndDate

Basically I need to run an update query that will find rows where id = x and EndDate = <empty> then update the row and insert EndDate = Date - 1 day.

What I am struggling with is date time methods in X++.
1. How can you subtract 1 day from a datetime value????
2. Query to update all rows where Id = X and EndDate = <empty>, how will this where clause looks like?


Please help ASAP.
Kind regards.
0
Comment
Question by:Marius0188
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
Agrippine earned 500 total points
ID: 24084655
Hi again ;-)

to check for an empty date, use the method datenull().
To set a field to date - 1, just write "systemdateget() - 1" ...

I hope the example helps.

Kind regards!

static void Job1(Args _args)

{

    InventTableModule   inventTableModule;

    ItemId              itemId = 'ESB-007';

    ;
 

    ttsbegin;
 

    while select forupdate inventTableModule

        where   inventTableModule.ItemId    == itemId

            &&  inventTableModule.PriceDate == datenull()

    {

        inventTableModule.PriceDate = systemdateget() - 1;

        inventTableModule.update();

    }
 

    ttscommit;

}

Open in new window

0
 

Author Comment

by:Marius0188
ID: 24085034
Just another question.
Let say you instead of using systedateget() you would like to use the date field from a row?

Would you simple - 1 as well to get the day before?


Thanks for the quick reply....
0
 
LVL 5

Expert Comment

by:Agrippine
ID: 24085205
Yes, I would
inventTableModule.PriceDate = inventTableModule.PriceDate - 1;

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Automatically creating a Trello card using data from a Microsoft Dynamics CRM record turned out to be an easy project that yielded great results.  Here's how I did this for an internal team at General Code.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now