Like 'PQR%'

sabzamsabzam Member Posts: 1,149
Dear All,

I have got a simple question (but to which I haven't got an answer obviously :)). How do write If x like 'PQR%' in Navision. This statement is written in sort of SQL. I know that the % sign is * in Navision; but what about the Like? Like means a word which is similar in this case it means a word which begins withe PQR. What code should I need in Navision to write down the same thing?

Answers

  • wmmasjwmmasj Member Posts: 10
    sabzam wrote:
    Dear All,

    I have got a simple question (but to which I haven't got an answer obviously :)). How do write If x like 'PQR%' in Navision. This statement is written in sort of SQL. I know that the % sign is * in Navision; but what about the Like? Like means a word which is similar in this case it means a word which begins withe PQR. What code should I need in Navision to write down the same thing?

    If you are trying to access data in a table you could try to create a filter on the table and use COUNT or FIND to see if there are any records that start with PQR.
    rec.SETFILTER(field, 'PQR*');
    
    IF rec.COUNT > 0 THEN
      MESSAGE('Found a match!!!');
    

    I belive this would do the trick!

    /Mathias
  • garakgarak Member Posts: 3,263
    ok, the Field is an text or code field.

    fast solution, there are some ...
    this is, if you cant filter
    
    if STRPOS(YOURFIELDORVARIABLE,'PQR') <> 0 then
      message('Blabla');
    
    or 
    
    if YOURVARIABLE[1] = 'P' and YOURVARIABLE[2] = 'Q' and YOURVARIABLE[3] = 'R' then
      message('fsdg');
    
    this is, if you will filter:
    
    YOURRECORD.setfilter(YOURFIELD,'PQR*');
    if YOURRECORD.isempty then
      message('No Record');
    
    Do you make it right, it works too!
  • sabzamsabzam Member Posts: 1,149
    Hi

    I couldn't use the filter. It has worked perfectly :). THanks for your immediate reply to both of you
Sign In or Register to comment.