DOTNET foreach
kenjes
Member Posts: 76
Hi
I have this .NET code :
Can I "convert" it to NAV 2016.. somehow
Thanks.
I have this .NET code :
foreach (DataRow JournalDR in objJournal.GetAllNonSyncedJournalsAndNonProcessed().Rows)
Can I "convert" it to NAV 2016.. somehow
Thanks.
0
Best Answer
-
create variable for JournalDR of dotnet dataype DataRow
FOREACH JournalDR IN objJournal.GetAllNonSyncedJournalsAndNonProcessed().Rows DO
BEGIN
//your code.
end;5
Answers
-
You need to either use the Item property or something similar (see https://msdn.microsoft.com/en-us/library/hh165881(v=nav.90).aspx), or use an enumerator object.
Below is an example where I search a Dictionary for a Value to get back the Key:VAR TableDict@1000000000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2"; PROCEDURE TableNameFromID@1000000007(TableNo@1000000000 : Integer) Name : Text; VAR Enum@1000000003 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2+Enumerator"; KeyVal@1000000002 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.KeyValuePair`2"; FieldNoDict@1000000004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2"; No@1000000005 : Integer; BEGIN IF ISNULL(TableDict) THEN FillTableDict; Enum := TableDict.GetEnumerator; WHILE Enum.MoveNext DO BEGIN KeyVal := Enum.Current; No := KeyVal.Value; IF No = TableNo THEN EXIT(KeyVal.Key); END; EXIT(FORMAT(TableNo)); END;0 -
NAV 2016 has FOREACH and you can use it for dotnet types.0
-
Hi ara3n
Yes, i know
but I can't figure out how to use it like :
foreach (DataRow JournalDR in objJournal.GetAllNonSyncedJournalsAndNonProcessed().Rows)0 -
create variable for JournalDR of dotnet dataype DataRow
FOREACH JournalDR IN objJournal.GetAllNonSyncedJournalsAndNonProcessed().Rows DO
BEGIN
//your code.
end;5 -
Thanks ara3n0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

