Case Of and option Field

pjfilipepjfilipe Member Posts: 10
When trying to execute the following code:


CASE SalesHeader."Document Type" OF
SalesHeader."Document Type"::Order,SalesHeader."Document Type"::Quote:
BEGIN

I get the followin error:
"Type conversion is not possible because 1 of the operators contains an invalid type. Option t_testcas Boolean"

Anyone knows what´s wrong in this expression.

Comments

  • oleschjoetholeschjoeth Member Posts: 74
    The structure should be something like this

    CASE SalesHeader."Document Type" OF
    SalesHeader."Document Type"::Order : x statement;
    SalesHeader."Document Type"::Quote : x other statement;
    END;
  • Dean_AxonDean_Axon Member Posts: 193
    CASE SalesHeader."Document Type" OF 
    SalesHeader."Document Type"::Order,
    SalesHeader."Document Type"::Quote: 
      BEGIN
    

    There's nothing wrong so far. It must be something to do with your next section of code as Navision will quite happily allow you to write different options values before the Colon so long as they are seperated by a comma.

    What are your next few lines of code ????
    Remember: Keep it simple
  • pjfilipepjfilipe Member Posts: 10
        CASE SalesHeader."Document Type" OF
          SalesHeader."Document Type"::Order, SalesHeader."Document Type"::Quote:
          BEGIN
          IF Archive.CheckSalesVersion(SalesHeader) THEN BEGIN
            Archive.StoreSalesDocument(SalesHeader,TRUE);
            CALCFIELDS(SalesHeader."No. of Archived Versions");
            IF SalesHeader."Bill-to Contact No." <> '' THEN
              SegManagement.LogDocument(
               3,SalesHeader."No.",SalesHeader."Doc. No. Occurrence",
                SalesHeader."No. of Archived Versions",DATABASE::Contact,SalesHeader."Bill-to Contact No."
                 ,SalesHeader."Salesperson Code",SalesHeader."Campaign No.",SalesHeader."Posting Description")
            ELSE
             SegManagement.LogDocument(
              3,SalesHeader."No.",SalesHeader."Doc. No. Occurrence",
               SalesHeader."No. of Archived Versions",DATABASE::Customer,SalesHeader."Bill-to Customer No.",
                SalesHeader."Salesperson Code",SalesHeader."Campaign No.",SalesHeader."Posting Description");
          END;
        END;
    

    This is the complete code statement.
    The problem is in the CASE statement, if I change it to an IF statement works good.
    It also seems very strange to me.
    Thanks for your help.

    Paulo
  • Dean_AxonDean_Axon Member Posts: 193
    Hi Paulo,

    bit too keen with the "Begin" statements :wink:

    Try this:
    END ELSE 
             SegManagement.LogDocument( ........your code continued......
    

    Hint:
    Try indenting your second begin statement another level. This will help you to track your begin-end statements.

    Dean
    Remember: Keep it simple
  • i4tosti4tost Member Posts: 208
    Missing one END statement. CASE OF also must finish with END;
  • pjfilipepjfilipe Member Posts: 10
    Thank you very much

    Paulo
  • DoomhammerDoomhammer Member Posts: 211
    what about use this:
    IF SalesHeader."Document Type" IN [SalesHeader."Document Type"::Order,SalesHeader."Document Type"::Quote] then begin
    
    ... ?

    :idea:
    Martin Bokůvka, AxiomProvis
  • Dean_AxonDean_Axon Member Posts: 193
    what about use this:

    Code:
    IF SalesHeader."Document Type" IN [SalesHeader."Document Type"::Order,SalesHeader."Document Type"::Quote] then begin
    ... ?

    that is another possible option, but I guessed that Paulo is not an experienced developer and I thought the other way might be easier ????
    Remember: Keep it simple
  • pjfilipepjfilipe Member Posts: 10
    You are right I'm new to C/SIDE,

    give me some more time and I hope to be helping instead of asking for help.

    Best Regards

    Paulo
  • DoomhammerDoomhammer Member Posts: 211
    pjfilipe wrote:
    You are right I'm new to C/SIDE,

    give me some more time and I hope to be helping instead of asking for help.

    Best Regards

    Paulo

    good luck :-) navision is easy to learn but hard to maintain :-)
    Martin Bokůvka, AxiomProvis
Sign In or Register to comment.