How to Use Reference Data Types in Microsoft Dynamics (Instead of Value Types)

By Maria Ocampo | February 28, 2020

How to use reference data types in microsoft dynamics (instead of value types)

Recently, I’ve come to learn a very interesting fact about data types (such as Lists and Dictionaries). For a little background:

  • A List data type is defined as a strongly typed list of objects that can be accessed by index. You can check all the methods available for List data type.
  • A Dictionary data type is defined as a collection of keys and values. You can check all the methods available for Dictionary data type.

The interesting part is that, for performance reasons, they are reference types (not value types).

In Microsoft Dynamics 365 Business Central, a reference type means that the variable does not hold a value in and of itself, but rather a reference to an instance of an object in memory.

When you pass this kind of variable as a parameter to a function, that function is receiving a reference to the object in memory and it will work directly on that object through the reference.

How to use reference data types | Example

Let me explain the concept with a simple example.

We can extract the list of overdue sales invoices using a List data type as shown in the following code:

Note that the parameter is not passed by var.

I will use a report to output for the results, for better organization.

As you can see, even if the parameter was not passed by var, it will come back with the results:

This happens because the List is a reference type. In both places, the report and the codeunit are pointing to the exact same object in memory.

 

Related Posts

Recommended Reading:

Manage U.S. Use Tax on Purchase Orders in Dynamics 365 Finance and Operations

  Managing sales tax requirements on your business purchase can be complicated, but Dynamics 365 Finance and Operations can help […]

Read the Article
5.19.22 Dynamics CRM

How to Write a Great Support Ticket in the Stoneridge Support Portal

Submitting a support ticket through the Stoneridge Support Portal is a quick and effective way to get assistance for any […]

Read the Article

Managing Your Business Through Uncertain Times Using Dynamics 365 Finance and Operations

  Dynamics 365 Finance and Operations (F&O) can help you make informed decisions on how to move your business forward. […]

Read the Article
5.13.22 Power Platform

Using Power BI Object Level Security

  The following article will demonstrate how to use Power BI Object Level Security to disable column data based on […]

Read the Article
5.12.22 Dynamics CRM

How to Use the Stoneridge Support Portal

Stoneridge Software’s support portal is an intuitive and useful function that makes it easy for you to access resources to […]

Read the Article
5.6.22 Dynamics GP

Dynamics GP Transaction Removal: Purchase Orders

  Are you having performance issues with Purchase Orders?  Do you find that there are old Purchase Orders on your […]

Read the Article
5.5.22 Dynamics GP

The Real Story about the Long-Term Future of Dynamics GP Support

I’ve seen a number of people put forward comment that Dynamics GP is going away and you have to get […]

Read the Article

New Features in Dynamics 365 Business Central 2022 Wave 1 Release – Financial Enhancements

The Dynamics 365 Businses Central 2022 Wave 1 Release has a lot of new and exciting features to help your […]

Read the Article
4.29.22 Dynamics GP

Dynamics GP Transaction Removals: Bank Reconciliation

  This is part 2 of a 3 part series on Dynamics GP Transaction Removals. These quick tips will hopefully […]

Read the Article

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X