SETRANGE DateFormula

idiotidiot Member Posts: 651
What is the syntax to perform SETRANGE for a DateFormula field?
eg SETRANGE for a certain Due Date Calculation for the Payments Terms table
NAV - Norton Anti Virus

ERP Consultant (not just Navision) & Navision challenger

Comments

  • DaveTDaveT Member Posts: 1,039
    Hi,

    Not sure what you what to acheive. A DateFormula is string used to increment/descrement a date. Would a FlowFilter e.g. "Date Filter" not suit better.

    Can you give an example of what you want to do.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • idiotidiot Member Posts: 651
    Payment Terms table
    I want to retrieve all records where the Due Date Calculation is 7D through code. (7D is not a constant but is the eg value).
    Can it be done without involving EVALUATE?
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • DaveTDaveT Member Posts: 1,039
    Hi,

    Use a SETFILTER
    i.e.

    SETFILTER( "Due Date Calculation", '7D' );
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • idiotidiot Member Posts: 651
    Thanks for you help.
    Works fine, didn't expect have to use SETFILTER...
    But now comes another part
    SETFILTER("Due Date Calculation", '<> %1', '7D');
    
    doesn't work
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • DaveTDaveT Member Posts: 1,039
    Hi,

    I'm assuming that this is giving a compile error. two options:

    use

    MyStr := '<>7D';
    SETFILTER( "Due Date Calculation", MyStr );

    and generate the '<>7D' using a string variable STRSUBSTNO etc.

    use

    EVALUATE( MyDateFormula, '7D' );
    SETFILTER("Due Date Calculation", '<> %1', MyDateFormula );

    and generate the '7D' with the EVALUATE command.
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • idiotidiot Member Posts: 651
    As I suspected, that means there is no direct way to work with SETFILTER/SETRANGE without involving another variable.
    Thanks for your help
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • DaveTDaveT Member Posts: 1,039
    Hi,

    Yes, I've always used a variable and never invested the time to investigate.

    Glad to Help :mrgreen:
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
Sign In or Register to comment.