COMPRESSARRAY() on Customized Dynamics NAV Reports

When it comes to customized reports, header information always contains the Company Information. Adding fields to report layout is a pretty repetitive task, time-consuming too.

We wanted to generalize the code and always call from a method rather hard-coding, or always referring the Company Information.
As Rasitha Chandrasekara talked about Facade Management, we added a method to capture this information in order to reuse.

So we are concatenating the Address, Address 2, Phone No., E-mail, Fax No., and website, breaking with the carrot(“^”) symbol.

So when we call it in SSRS/RDLC reporting, we write the expression as, 
=Replace(First(Fields!Company_Details.Value, “DataSet_Result”), “^”, Environment.NewLine())

The interesting part is, the COMPRESSARRAY() method that we have used in here.

There are 6 fields of the Company Information on the function, and each takes an array element. What if any field in here is empty?
COMPRESSARRAY() eradicates this problem by shifting all empty array elements to the end of the array.

But when you are using NAV 2016, you have no luxury of using multidimensional arrays. This is what they say in the Developer Documentation:

In Microsoft Dynamics NAV 2016, it is not supported to use the COMPRESSARRAY function on multidimensional arrays. In earlier versions, COMPRESSARRAY works for arrays of arrays.

Fun fact: We have used this method for nearly 20 customized reports now. This will continue.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.