Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Get date from DatabaseLog Value

(1) ShareShare
ReportReport
Posted on by 85

7288.question.png

How to get this update date(number 2), from status "Previous value : Scheduled" and updated "Value : Released" < this value is only one on databaselog


while select inventDim
            join prodTab
            where prodTab.InventDimId == inventDim.inventDimId
            && prodTab.ProdStatus == ProdStatus::Released >> i think this should be changed, but i dont know the solution

join sysLog
                    where sysLog.LogRecId == inventDim.RecId
                    && sysLog.createdDateTime >= fromDate
                    && sysLog.createdDateTime <= toDate

{

            Tmp.clear();

            Tmp.inventBatchId = inventDim.inventBatchId;

            Tmp.ValidFrom = sysLog.createdDateTime;

            Tmp.insert();

}


Please help.
Thanks in advance.

*This post is locked for comments

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Get date from DatabaseLog Value

    It gives you a list of containers. Each container contains a field ID, the new value and the old value. For example, if three fields changed, you'll get a list with three containers. You can use ListEnumerator class to walk through the list and you'll check which container is for the field you're interested in. Then you'll take the values from this container.

    Like this:

    ListEnumerator enumerator = dbLog.getDataAslist().getEnumerator();
    
    while (enumerator.moveNext())
    {
        [fieldId, newValue, oldValue] = enumerator.current();
        if (fieldId == fieldNum(ProdTable, ProdStatus))
        {
            // do something
            break;
        }
    }


  • Ardhi A Rahman Profile Picture
    Ardhi A Rahman 50 on at
    RE: Get date from DatabaseLog Value

    Hi Martin!

    Can u give me a sample to doing that SysDatabaseLog.getDataAsList() as a Previous and new Value.

    Just for e.g. doing that to get the answer.

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Get date from DatabaseLog Value

    Do you realize that your query uses the current value of prodTab.ProdStatus, not the value at the time of logging?

    What you see as [1] isn't ProdTable, it's in SysDatabaseLog.Data. It's a container, but you can use SysDatabaseLog.getDataAsList() to get values in a list.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: Get date from DatabaseLog Value

    Hi Rahmat,

    The changes of the status old/new value is stored in a blob in the database log. You can have a look at the form how these values are extracted to be readable on the form.

    I wonder what you want to achieve with your coding. Depending on the business requirement, we can help you with a solution direction.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans