Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Query - select whole object instead of specific columns

Posted on by Microsoft Employee
Hi, 

I've written this C/AL code to query dimensions from the database and for each
dimension I query its dimension values. The queries work as expected, I use
'MESSAGE' function to display and test values - it's fine. The problem is that I
need to pass the dimensions and dimension values to a code unit and I'd like to
pass them as objects, instead of arrays of string (using Array .NET interoperability)
- for each specific property I must have different array and it's not practical for me.
So here is my C/AL code, can you give me a piece of advice how to proceed?

FOREACH CurrentDimensionTemp IN DimensionNamesArray DO BEGIN DimensionsQuery.SETFILTER(Code, '=' + CurrentDimensionTemp.ToString()); DimensionsQuery.OPEN(); WHILE DimensionsQuery.READ DO BEGIN DimensionValuesQuery.SETFILTER(Dimension_Code, '=' + DimensionsQuery.Code); DimensionValuesQuery.OPEN(); WHILE DimensionValuesQuery.READ DO BEGIN MESSAGE(DimensionsQuery.Code + ' : ' + DimensionValuesQuery.Code); END; END; END;

Thanks!

*This post is locked for comments

  • Verified answer
    keoma Profile Picture
    keoma 32,675 on at
    RE: Query - select whole object instead of specific columns

    create a new global function in your codeunit. declare one or two paramters of type record and subtype dimension/dimension value for the function, set the paramters as VAR paramter. so you can pass a single or a set of records to your function.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Query - select whole object instead of specific columns

    Yeah, I'm planning to use ExportToXML function from the 432 Codeunit to export my dimension and dimension values along with the rest of the xml structure (because 432 Codeunit sets things like glAccounts, etc...).

  • mmv Profile Picture
    mmv 11,465 on at
    RE: Query - select whole object instead of specific columns

    Hi,

    You may write the data in an XML file and pass it.  But 432 Codeunit expects a record of "Business Unit" or are you planning to use a specific function from CU 432?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Query - select whole object instead of specific columns

    Hi,

    I need to pass my dimension and dimension values to Consolidation Import/Export XMLPort through Consolidation code unit (432) and to export them in XML format along with default consolidation export.

  • mmv Profile Picture
    mmv 11,465 on at
    RE: Query - select whole object instead of specific columns

    Hi,

    Could you mention your requirement?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans