Friday, June 22, 2018

Create comma separated list from table column data

I made a report to show assets that weren't on the appropriate PM template and to make it easy to add the exact assets on the PM template phase screen, I wanted to convert column data into a single array or comma separated list. I did some research and cobbled together a couple online examples to solve the problem. 

On the data set beforeOpen script:

footlist = "";

On the data set beforeOpen script:

foolist +=row['asset_tag'] + ", ";

On the layout, I added a dynamic text following the table:

foolist=foolist.replace(/,\s*$/, "");
foolist;

Here is how it looks in the report designer.
Here is how it looks on the report. That list can be copied and pasted into the template phase to search for assets. This is especially helpful if you have a template requiring multiple asset classifications in multiple buildings as it defines the exact list of assets. 

This approach could also be used for building lists of shop people to search for daily assignments to compose a url.