Validating Option field

idiotidiot Member Posts: 651
Why doesn't this work in dataport for Sales Header
VALIDATE ("Document Type", GETFILTER ("Document Type"));?

The error
Type conversion is not possible because 1 of the operators contains an invalid type

Option := Text


What should the correct syntax be?
Thanks
NAV - Norton Anti Virus

ERP Consultant (not just Navision) & Navision challenger

Answers

  • sendohsendoh Member Posts: 207
    because the return value of getfilter function is text
    Sendoh
    be smart before being a clever.
  • idiotidiot Member Posts: 651
    Right
    So how to convert Text datatype to Option datatype?
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • sendohsendoh Member Posts: 207
    try this one..

    Text datatype: vtempTextopt
    option Datatype: vtexttoopt

    vtempTextopt := GETFILTER("Document Type");

    IF EVALUATE(vtexttoopt,vtempTextopt) THEN begin
    VALIDATE("Document Type",vtexttoopt);
    Sendoh
    be smart before being a clever.
  • idiotidiot Member Posts: 651
    Thanks.

    Was playing with evaluate but could quite get the syntax right.

    Thanks


    Another question
    Can I assign a datatype Option variable OptionString options?

    DocType.OptionString := SalesHeader."Document Type".OptionString?
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • girish.joshigirish.joshi Member Posts: 407
    Yes, you can, but you should make sure that the order of your options in teh option variable is the same as the order of your options in the field.
  • MorilenMorilen Member Posts: 30
    I am getting the same error as the original poster with this:

    IF "Type" = 'G/L Account' THEN
    "50025" = ''
    ELSE
    ItemInfo.GET("No.")

    50025 is the ID for the text box where the value is displayed, and it is used for pulling in the Base unit of measure from the item card onto the order. Source Expression is: ItemInfo."Base Unit of Measure"


    I am probably doing it wrong, but the problem I was originally trying to avoid with that code was related to me just using:
    ItemInfo.GET("No.") and it would not allow me to print any PO with a GL account directly referenced on a line. Also when I make an order from a blanket order it returns the error, "Item Number " Does not Exist, but the item is definitely in the system under that number. It also prints just fine when the same order is created through POs and not Blanket Orders.

    Any assistance would be appreciated.
  • girish.joshigirish.joshi Member Posts: 407
    The reason you are getting your error is because of your comparison
    if type = 'G/L Account'
    
    should be
    if type = type::"G/L Account" then
    

    because type is an option string.

    However, the rest of your code is a little garbled as well. You will want to set the source expressions of text box 50025 to a variable.

    Then set the variable to = '' if it's not an item, or the value from your iteminfo if it's an item. Just checking for g/l accounts may not be enough
  • DenSterDenSter Member Posts: 8,304
    Instead of:
    IF "Type" = 'G/L Account' THEN
    
    do this:
    IF Type = Type::"G/L Account" THEN
    
    To evaluate option values, you need to use ::

    Alternatively, you could do this:
    IF FORMAT(Type) = 'G/L Account' THEN
    
    in which case the value of Type is convered to a text
  • MorilenMorilen Member Posts: 30
    I used:


    IF Type <> Type::Item THEN
    CLEAR(ItemInfo)
    ELSE
    ItemInfo.GET("No.")

    with ItemInfo."Base Unit of Measure" as the source code for the Textbox on the report and it is working perfectly now.

    Thank you both for the help.
Sign In or Register to comment.