Sorting a Report by Document Date

d7onod7ono Member Posts: 6
I have a report already written but I cannot sort by Document Date (ascending), tried adding a key but it throws up an error.

The vendor ledger entry table does not have an active key that starts with the following field(s) Document Date.

Could I write a piece of code in the C/AL (getafterrecord) to resolve this instead of adding a key ?

If so can you help with the actual wording of the code.

(My report is based on Vendor table with vendor ledger entry indented under if that helps)

Comments

  • SogSog Member Posts: 1,023
    Could you provide us with the error that nav throws when you add the key.
    It could save you a lot of code.

    You can try to define the DataItemTableView in the properties of the dataitem in your report.
    Try
    Sorting("Document Date")
    
    Just select the Dataitem in your report designer and press Shift + F4 to view the properties.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • d7onod7ono Member Posts: 6
    Sog wrote:
    Could you provide us with the error that nav throws when you add the key.
    It could save you a lot of code.

    You can try to define the DataItemTableView in the properties of the dataitem in your report.
    Try
    Sorting("Document Date")
    
    Just select the Dataitem in your report designer and press Shift + F4 to view the properties.

    Hi
    Tried above comes up with the same message
    "The vendor ledger entry table does not have an active key that starts with the following field(s) Document Date."
  • SogSog Member Posts: 1,023
    What error do you receive when you try to add the key to the vendor ledger entry table?
    Because it is very odd that that doesn't work.
    Sorting on a non key field in code can be very hard because a report steps trough the filtered and sorted table record for record. And when I think about it, it seems impossible to do (but I have to admit that I'm no NAV expert).
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • BeliasBelias Member Posts: 2,998
    depending on your needs, you can create a temptable variable for vendor ledger entries, copy the document date in the posting date of the temptable, modifyall and order the temptable by posting date.
    then show the temptable...I hope you're a developer :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • DaveTDaveT Member Posts: 1,039
    Belias wrote:
    depending on your needs, you can create a temptable variable for vendor ledger entries, copy the document date in the posting date of the temptable, modifyall and order the temptable by posting date.
    then show the temptable...I hope you're a developer :mrgreen:
    I like your idea but very dangerous in the wrong hands. Better be sure of the temporary flag :wink:
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • BeliasBelias Member Posts: 2,998
    DaveT wrote:
    Belias wrote:
    depending on your needs, you can create a temptable variable for vendor ledger entries, copy the document date in the posting date of the temptable, modifyall and order the temptable by posting date.
    then show the temptable...I hope you're a developer :mrgreen:
    I like your idea but very dangerous in the wrong hands. Better be sure of the temporary flag :wink:

    Right, this is the meaning of
    I hope you're a developer :mrgreen:
    :-({|=
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.