List Form Sorting

cole.rutherfordcole.rutherford Member Posts: 12
Is there a way to code how I want a form to sort?

I have a form that I needs sorting different way depending where the user tries to view the form. Thanks in advance.

Comments

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Yes.

    You can do it in two ways

    If you just want to set different than default sorting order, different but still fixed, you can simply set RunFormView property on button which is used to run the form. IF the form is launched via button

    In order to have full flexibility you can write some code in OnLookup trigger.

    1. Create variable based on form fou want to display
    2. Create record on wchich the form is based
    3. use SETCURRENTKEY on record to select key you want to display
    4. you may also use SETFILTER if there is a need to narrow number of records
    5. write formbasedvariable.SETTABLEVIEW(recordbasedvariable)
    6. write formbasedvariable.RUNMODAL or formbasedvariable.RUN

    If you want to pick some selected data from displayed form you'll have to write additional some code.

    Regards,
    Slawek.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • cole.rutherfordcole.rutherford Member Posts: 12
    Appreciate the help.
  • cole.rutherfordcole.rutherford Member Posts: 12
    Is there a way to set the order, ascending or decending, in code? We have all the code for the filtering, we just need to sort accordingly.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Is there a way to set the order, ascending or decending, in code? We have all the code for the filtering, we just need to sort accordingly.

    Seach for the function called ASCENDING in the C/SIDE help.
  • David_CoxDavid_Cox Member Posts: 509
    There is a Table.SETVIEW(String) and GETVIEW, in V4, But the help is not any good, no example.

    Just create a form with the View you want then copy the SourceTableView, don't save the form.

    Like I have done Here with the Item Table.

    myItem.SETVIEW('SORTING(No.) ORDER(Descending)');

    Please let us know if it works ok.
    From Dynamics help
    SETVIEW (Record)
    Use this function to set the current sort order, key and filters on a table.

    Record.SETVIEW(String)
    String

    Data type: text or code

    The string format is the same as the SourceTableView property on forms.

    Comments
    The value of the String parameter can be one returned by GETVIEW.

    If the SETVIEW function is executed with an empty string, all filters are removed and the primary key is used.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.