Search code examples
reporting-servicesdynamics-crmsql-server-data-toolsfetchxmldynamics-crm-365

Use a parameter to control the number of malings labels for a FetchXML based report?


I'm trying to build a simple mailing label report that upon runtime lets the user choose the amount of labels to be generated for each record.

Solutionwize I'm thinking a report parameter is the way to go for the user to choose the amount of labels per record to be generated, but after that I'm kind of stuck.

The label itself will only contain 1 column, an ID.

Since it's a Dynamics 365 CRM online environment I have to find a solution without using SQL. I'm restricted to using only FetchXML and reporting services (SSDT).

Any help appreciated.


Solution

  • This works if the number of mailing labels per record to create is reasonable low. If you need to create hundreds of labels for each record I would say this solution is too cumbersome.

    This is how I managed to get it to work:

    Steps

    1. Create a "normal" mailing label-report: a list with the number of columns that matches the mailing label format you want to create.
    2. Create a report parameter with predefined values, for example 1-10.
    3. In the report designer, duplicate the number of rows in your list, so that you have the same amount as you specified earlier in the parameter you created in step 2. In my case I now have 10 rows.
    4. Hide rows 2-10 so they are not visible unless the user selects the parameter value that corresponds to the number of rows to be shown. Create an expression for that. Just right click on the rown and under visability there's an option to show/hide based on expression.

    Expression example

       Row 2: =IIF(Parameters!Amount.Value < 2, True, False)
       Row 3: =IIF(Parameters!Amount.Value < 3, True, False)
    

    While this approach works and achieves my goal, it's not as elegant of a solution as I was hoping for. Would've been nicer to make the solution dynamic.