Another simple development question

djswimdjswim Member Posts: 277
So, I'm trying to run a line of code ONLY IF the Document Type field in the Sales Line table is NOT "Order" or "Quote". Here is what I have:
IF "Document Type" <> "Document Type"::Order AND "Document Type" <> "Document Type"::Quote THEN FunctionName();

I'm getting a type conversion error... Option AND Option.

This is 2009 SP1, although I'm pretty sure this is just a syntax thing I can't remember. As always, the help is very much appreciated.
"OMG ALL MY DATA IS GONE"
"Show All..."
"Oh..."

Answers

  • anna_sicosbtanna_sicosbt Member Posts: 7
    djswim wrote:
    So, I'm trying to run a line of code ONLY IF the Document Type field in the Sales Line table is NOT "Order" or "Quote". Here is what I have:
    IF "Document Type" <> "Document Type"::Order AND "Document Type" <> "Document Type"::Quote THEN FunctionName();
    

    I'm getting a type conversion error... Option AND Option.

    This is 2009 SP1, although I'm pretty sure this is just a syntax thing I can't remember. As always, the help is very much appreciated.

    Try:
    IF ("Document Type" <> "Document Type"::Order) AND ("Document Type" <> "Document Type"::Quote) THEN FunctionName();
    
    Anna Perotti
    Dynamics NAV MVP (2005-2010)
  • SavatageSavatage Member Posts: 7,142
    Just verify that these are your left over options....[Invoice,Credit Memo,Blanket Order,Return Order]
  • djswimdjswim Member Posts: 277
    Perfect, thank you so much! As always, you guys rock!
    "OMG ALL MY DATA IS GONE"
    "Show All..."
    "Oh..."
  • David_SingletonDavid_Singleton Member Posts: 5,479
    djswim wrote:
    So, I'm trying to run a line of code ONLY IF the Document Type field in the Sales Line table is NOT "Order" or "Quote". Here is what I have:
    IF "Document Type" <> "Document Type"::Order AND "Document Type" <> "Document Type"::Quote THEN FunctionName();
    

    I'm getting a type conversion error... Option AND Option.

    This is 2009 SP1, although I'm pretty sure this is just a syntax thing I can't remember. As always, the help is very much appreciated.

    Why not
    IF "Document Type" NOT IN ["Document Type"::Order."Document Type"::Quote] THEN 
      FunctionName();
    

    Same result, but reads much easier.
    David Singleton
  • djswimdjswim Member Posts: 277
    I tried the "NOT IN" route but did something wrong because I got an error message saying that it needed to be a TRUE/FALSE or something like that. I can't remember.
    "OMG ALL MY DATA IS GONE"
    "Show All..."
    "Oh..."
  • ReinhardReinhard Member Posts: 249
    NOT IN is not a valid syntax as far as I'm aware.

    I always have to do this:
    IF NOT ("Document Type" IN ["Document Type"::Order."Document Type"::Quote]) THEN 
      FunctionName();
    
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Reinhard wrote:
    NOT IN is not a valid syntax as far as I'm aware.

    I always have to do this:
    IF NOT ("Document Type" IN ["Document Type"::Order."Document Type"::Quote]) THEN 
      FunctionName();
    


    I think you are probably right. I just wrote off the top of my head. Yours looks better. :thumbsup:
    David Singleton
Sign In or Register to comment.