Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Query in X++

Posted on by 170

I'm trying to do a test, but I'm not getting the expected result... I need to get all vendors that had an update in VendTable, DirPartyTable, LogisticsPostalAddress or LogisticsElectronicAddress. I have created the query below, but is just getting the modifiedDateTime from VendTable. What I'm doing wrong?

64850.Screenshot_5F00_1.png

*This post is locked for comments

  • Rati Sharabidze Profile Picture
    Rati Sharabidze 612 on at
    RE: Query in X++

    Hi,

    Why do you use ||? You should use &&.

    Also, there are 2 ways of using them.

    1) You have to write your single condition after selecting the table, for example after join table1 or something, in where clause.

    2) You set all conditions after writing all joins.

    Another

    BR

  • Suggested answer
    Rafael Araujo Profile Picture
    Rafael Araujo 170 on at
    RE: Query in X++

    I did using 5 independent queries and exporting the result (Company and Vendor) to a staging... after I will export the vendors using the vendor list of the staging table. Is not beautiful, but is working... Thanks everyone!

  • Rafael Araujo Profile Picture
    Rafael Araujo 170 on at
    RE: Query in X++

    Do not worked. Is showing all vendors if I add the where modifiedDateTime in final of query...

  • Pradeep_Prakash Profile Picture
    Pradeep_Prakash 715 on at
    RE: Query in X++

    if the above query results right in SQl. The below code should work:

    Utcdatetiem dt = UtcDatetime::newDatetime(datetime);

    while select vendtable

    join dirPartyTable

    where dirPartyTable.Recid == vendTable.Party

    outer join LGT

    where LGT.REcid == dirPartyTable.PrimaryContactEmail

    outer join LogLOcation

    where LogLocation.RecId == dirPartyTable.PrimaryAddressLocation

    outer join LogPostalAdd

    where LogPostalAdd.Location == LogLocation.RecId

    and (vendor.ModifiedDateTime > dt ||

    dirPartyTable.ModifiedDateTime > dt ||

    LGT.ModifiedDateTime > dt ||

    LogLOcation.ModifiedDateTime > dt ||

    LogPostalAdd.ModifiedDateTime > dt )

  • Rafael Araujo Profile Picture
    Rafael Araujo 170 on at
    RE: Query in X++

    Hi Pradeep,

    Do you have any idea how can I solve it?

  • Suggested answer
    Pradeep_Prakash Profile Picture
    Pradeep_Prakash 715 on at
    RE: Query in X++

    Hi Rafael,

    In OR cases, when the first condition is true. System will not next for the other conditions. Since system is able to fetch record vendor.modifiedDateTime>dt . It will stop will not check for other conditions.

    Regards,

    Pradeep

  • Rafael Araujo Profile Picture
    Rafael Araujo 170 on at
    RE: Query in X++

    Basically, I want the query below in X++.

    8713.Screenshot_5F00_1.png

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: Query in X++

    Hi Rafael,


    Remove vendor.modifiedDateTime>dt  judgment condition and whether there is correct query data?

  • Rafael Araujo Profile Picture
    Rafael Araujo 170 on at
    RE: Query in X++

    Hi Brandon,

    I changed the myDateTime as a utcDateTime variable, but the result is the same.

    I test just with VendTable and DirPartyTable, but I just get the modifiedDateTime from the VendTable... the AX is ignoring the DirPartyTable... I don't know why...

    I'm using outer join because some vendor couldn't have email, phone or address, but I need to show these vendors too.

  • Suggested answer
    BrandonSA Profile Picture
    BrandonSA 1,669 on at
    RE: Query in X++

    Hi

    Why don't you declare myDateTime as a utcDateTime variable? Why are you using a string and then converting it's format? I would change that for starters.

    Rather take dt and assign a data value to it directly. Also, when you debug, have you checked that dt has the correct value - the value that you're expecting?

    Maybe get rid of all the joins, and just run the job on the vendor table to make sure that your date comparisons are in the right format etc. Then add the joins 1 by 1.

    Out of curiosity, why are you using outer joins?

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans