TESTFIELD with 2 condition in OR

andy76andy76 Member Posts: 616
Hello,

I should make a TESTFIELD as in ex. following (that doesn't go right):


TESTFIELD(Type,((Type::"G/L Account") OR (Type::"Item")) )

I want the message if the type is not "G/L Account" and is not "Item".

Is that possible or do I have to use IF statement and message with text constant?

Thank you

Comments

  • BeliasBelias Member Posts: 2,998
    if type <> type::glaccount then
      testfield(type,type::item);
    
    if type <> type::item then
      testfield(type,type::glaccount);
    

    it's a bit ugly (if you have to add another condition you will be in trouble) but i think it works 4 your scenario(never tried)...
    at least you don't have to create a new text constant

    :mrgreen:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    andy76 wrote:
    Hello,

    I should make a TESTFIELD as in ex. following (that doesn't go right):


    TESTFIELD(Type,((Type::"G/L Account") OR (Type::"Item")) )

    I want the message if the type is not "G/L Account" and is not "Item".

    Is that possible or do I have to use IF statement and message with text constant?

    Thank you
    if (type <> Type::"G/L Account") AND (type <> Type::"Item") THEN
      Fielderror(type); 
    

    in this case if Type is resource the error message will be:
    "type must not be Resource in Sales Line blah blah""
    David Singleton
  • MbadMbad Member Posts: 344
    To make it easier to understand using
    if not type in [type::"g/l account",type::Item]
    
    is much easier to read.
  • OfLightOfLight Member Posts: 7
    Hello,

    if not type in [type::"g/l account",type::Item] doesn't work ! :-k
    better try

    Here is the message displayed
    Microsoft Dynamics NAV
    This prefix operator cannot be used on Option.

    OK


    if (type <> Type::"G/L Account") AND (type <> Type::"Item") THEN
    Fielderror(type);
    Do it your self
  • garakgarak Member Posts: 3,263
    Try this. Type is a field, like in table 37 or 39
    if not (Type in [Type::"G/L Account",Type::"Item"]) then
      FIELDERROR(Type,'Must be "G/L Account" or "Item"');
    

    But other question. What is with type BLANK like for the "ext. Text" of an Item or other Description lines with a BLANK type?
    Do you make it right, it works too!
  • BeliasBelias Member Posts: 2,998
    garak wrote:
    Try this. Type is a field, like in table 37 or 39
    if not (Type in [Type::"G/L Account",Type::"Item"]) then
    FIELDERROR(Type,'Must be "G/L Account" or "Item"');
    

    But other question. What is with type BLANK like for the "ext. Text" of an Item or other Description lines with a BLANK type?
    if not (Type in [Type::"0",Type::"Item"]) then
    FIELDERROR(Type,'Must be "G/L Account" or "Item"');
    

    does not work?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.