How to pass constant of LineType::Item to a proc

markclemarkcle Member Posts: 65
Hi All

Writing an AL extension and need to call a proc that finds all sales lines of Type "Item", How do I pass the constant "Item".

I'm calling from a subscription on a Sales Header, so i can pass rec."Document Type" for the Doc Type, but can't figure out how to pass LineType of Item

Can someone point me in the right direction

Here's my proc definition:
   local procedure DeleteLines(var DocNo: code[20]; var DocType: Option; var ItemType: Option; FilterString: Text)

Here's my call:
    DeleteLines(rec."No.",  rec."Document Type", [b]'ITEM'[/b], 'FLOC | FCOM | FRES | FLIFT');


Thanks

Mark

Best Answers

Answers

  • navdevelopernavdeveloper Member Posts: 23
    Hi,

    You can pass ItemType::ITEM

    Thanks,
  • markclemarkcle Member Posts: 65
    Thanks all. I'd previously tried both suggestions (2 and temp record variable and got same error" can;t convert in to type Option")

    It was the parameter declaration on my DeleteLines Proc.

    I mistakenly had:
    local procedure DeleteLines(var DocNo: code[20]; var DocType: Option; var ItemType: Option; FilterString: Text)
    

    removing var in from front of the ItemType param fixed it.

    I guess I'm not clear on how when to use var on a proc definition. I looked at the AL programming guide: https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-methods#CallMethod and it uses var in one parameter, but there's no explanation of it.

    So when would I used "var: in the proc parameter and what does it do?

    Also, how do I pass by Ref vs pas by Value?

    TIA

    Mark
  • markclemarkcle Member Posts: 65
    Thanks a lot!
Sign In or Register to comment.