get a record based on two values

olafolaf Member Posts: 5
edited 2005-05-11 in Navision Attain
Hallo,

I need to select a value from a database with getRecord. The problem is, that I have to select a warehouse code from the report header to use this code to select later in the line the right sku to get a record identified with the item number.

this could be the code to get the Record:
IF getLocation.GET ("Item No.") THEN ...

how can place the value for the SKU?
Later !

Take a look on my personal website (if you like :))

Comments

  • RobertMoRobertMo Member Posts: 484
    Maybe you should check the PrimaryKey of the record you wnat to retrieve and then decide whether to use rec.GET or rec.FIND function.

    And of course read carefully help for both functions (and some more also). Then you will get the idea.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • olafolaf Member Posts: 5
    Hallo Robert,

    never used rec.FIND before, i will give it a try.

    The problem is what i see is, I got a stock keeping code from the header. then in the row i have to select a location based on an article number and the stock keeping code from the haeder. I will keep you informed tomorrow...
    Later !

    Take a look on my personal website (if you like :))
  • Jelias1Jelias1 Member Posts: 35
    GET() only works if you give it the parameters of the primary key. However, you can use FIND('-') to get a record. Many times you can narrow a search down to one record using FIND, even though it is capable of returning multiple records that meet the search criteria. You establish the criteria by using SETRANGE and SETFILTER on the table variable that calls FIND. Hope this helps.
    hj
  • olafolaf Member Posts: 5
    Hallo,

    Thank you all for the help...

    The example for FIND in the manual (ver. 3.10a) is a little strange (not really about the find function).

    Maybe someone can post a short example about how to use the function?
    Later !

    Take a look on my personal website (if you like :))
  • Jelias1Jelias1 Member Posts: 35
    CLEAR(AEICheckSalesLine);
    JECheckSalesLine.RESET;
    JECheckSalesLine.INIT;
    JECheckSalesLine.SETRANGE(JECheckSalesLine."Document Type","Document Type");
    JECheckSalesLine.SETRANGE(JECheckSalesLine."Document No.","Document No.");
    JECheckSalesLine.SETFILTER(JECheckSalesLine."Shortcut Dimension 1 Code",'<>%1','');
    IF JECheckSalesLine.FIND('-') THEN BEGIN

    This example shows how to use a combination of SETRANGE and SETFILTER to narrow down the search.

    The rule I follow is to use GET if I have all of the primary key information and to use FIND if I do not have the full data of the primary key.

    Hope this helps.
    j :)
  • awarnawarn Member Posts: 261
    One more tip which is an absolute necessity if you are using SQL backend:

    ALWAYS before setting ranges use a setcurrentkey. AS MUCH AS POSSIBLE the key you use should contain the fields you are sorting by, and the set ranges should be in the same order as the fields in the key.

    If you do not use a SETCURRENTKEY Navision will assume you want to use the primary key, which if you are doing a FIND should really not be the best key at all...

    JECheckSalesLine.RESET;
    JECheckSalesLine.INIT;

    JECheckSalesLine.SETCURRENTKEY("Document Type", "Document No.", "Shortcut Dimension 1 Code");

    JECheckSalesLine.SETRANGE(JECheckSalesLine."Document Type","Document Type");
    JECheckSalesLine.SETRANGE(JECheckSalesLine."Document No.","Document No.");
    JECheckSalesLine.SETFILTER(JECheckSalesLine."Shortcut Dimension 1 Code",'<>%1','');
    IF JECheckSalesLine.FIND('-') THEN BEGIN


    Take it from someone who has spent time re-writing posting routines to make them faster...

    -a
  • Jelias1Jelias1 Member Posts: 35
    An excellent point. It made me rewrite my routine. Thanks. :)
  • olafolaf Member Posts: 5
    @Jelias1

    thanks, it works perfect!!!
    Later !

    Take a look on my personal website (if you like :))
Sign In or Register to comment.