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

markcle
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:
Here's my call:
Thanks
Mark
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
0
Best Answers
-
You can create a variable inside your function of type Record "Sales Line", like
SalesLine: Record "Sales Line";
And then call your function like:DeleteLines(rec."No.", rec."Document Type", SalesLine.Type::Item, 'FLOC | FCOM | FRES | FLIFT');
Alternatively, since you can refer to options also as indexes the strings represent, you can lookup the existing options of "Sales Line".Type, find that it's:
" ,G/L Account,Item,Resource,Fixed Asset,Charge (Item)"
meaning that "Item" is index 2. With that, you can also call your function like:DeleteLines(rec."No.", rec."Document Type", 2, 'FLOC | FCOM | FRES | FLIFT');
5 -
Answers
-
Hi,
You can pass ItemType::ITEM
Thanks,0 -
You can create a variable inside your function of type Record "Sales Line", like
SalesLine: Record "Sales Line";
And then call your function like:DeleteLines(rec."No.", rec."Document Type", SalesLine.Type::Item, 'FLOC | FCOM | FRES | FLIFT');
Alternatively, since you can refer to options also as indexes the strings represent, you can lookup the existing options of "Sales Line".Type, find that it's:
" ,G/L Account,Item,Resource,Fixed Asset,Charge (Item)"
meaning that "Item" is index 2. With that, you can also call your function like:DeleteLines(rec."No.", rec."Document Type", 2, 'FLOC | FCOM | FRES | FLIFT');
5 -
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
Mark0 -
-
Thanks a lot!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions