Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Print multiple records...
Finance forum
Unanswered

Print multiple records using SSRS report

Posted on by 2
Hi guys,
 
As part of a development task i have created a SSRS Report to create labels for a car key tag. In my project i have created the Contract Class, the Data Provider Class and the Controller class. Additionally, i have created the Temp table with all the necessary fields for the label. Then i created the report and added the dataset coming from the Data Provider class. This dataset contains 5 fields that will be displayed on my report for each record chosen on the UI. I created then the below precision design with a static field and 5 fields coming from the DP class. I don't have any row groups or column groups.

Then i built the project and deployed the report on my DEV environment. I tested it but i am facing a problem which i am unable to fix. Basically, if on F&O i select only 1 record the report is printed correctly on PDF and Word as below:
However, if i select more than 1 record i am still getting the same result of only showing 1 record (sometimes it's the first one and others it's the last one). 
Do you have any idea of how i can surpass this issue and print in separate pages the Tag for each selected record? 

Example:

Please find my DP class below:
 
/// <summary>
/// HERPrintLabelKeyTagDP
/// </summary>
[
    SRSReportQueryAttribute(queryStr(HERPrintLabelKeyTag)),
    SRSReportParameterAttribute(classStr(HERPrintLabelKeyTagContract))
]
    public class HERPrintLabelKeyTagDP extends SrsReportDataProviderPreProcess
    //SrsReportDataProviderBase
{
    HERPrintLabelKeyTagContract                contract;
    public HERPrintLabelKeyTagTmp              printLabelKeyTag;
    /// <summary>
    /// HERPrintLabelKeyTagTmp
    /// </summary>
    /// <returns>HERPrintLabelKeyTagTmp</returns>
    [SRSReportDataSetAttribute(tablestr(HERPrintLabelKeyTagTmp))]
    public HERPrintLabelKeyTagTmp getTmpTable()
    {
        select printLabelKeyTag;
        return printLabelKeyTag;
    }
    /// <summary>
    /// insertTmpTable
    /// </summary>
    /// <param name = "_amDeviceId">_amDeviceIds</param>
    private void insertTmpTable(AMDeviceId _amDeviceId)
    {
        AMDeviceTable                   amDeviceTable;
        AMDeviceTableMaster             amDeviceTableMaster;
        AMRentDevice                    amRentDevice;
        AMDeviceFuel                    amDeviceFuel;
        AMDeviceTransmission            amDeviceTransmission;
        //HERPrintLabelKeyTagTmp          printLabelKeyTag;
        select firstonly amDeviceTable
            where amDeviceTable.DeviceId == _amDeviceId
            join amDeviceTableMaster
            where amDeviceTableMaster.MasterId == amDeviceTable.MasterId;
        if (amDeviceTable)
        {
            select firstonly amRentDevice
                where amRentDevice.DeviceId == amDeviceTable.DeviceId;
        }
        if (amDeviceTableMaster)
        {
            select firstonly amDeviceFuel
                where amDeviceFuel.FuelId == amDeviceTableMaster.FuelId;
            select firstonly amDeviceTransmission
                where amDeviceTransmission.TransmissionId == amDeviceTableMaster.TransmissionId;
        }
        ttsbegin;
        printLabelKeyTag.clear();
        printLabelKeyTag.UnitNumber                 = amDeviceTable.HERUnitNumber;
        printLabelKeyTag.ModelId                    = amDeviceTableMaster.DeviceName;
        printLabelKeyTag.FuellDescription           = amDeviceFuel.Description;
        printLabelKeyTag.DriveTrainId               = amDeviceTableMaster.DriveTrainId;
        printLabelKeyTag.TransmissionDescription    = amDeviceTransmission.Description;
        printLabelKeyTag.RegistrationNumber         = amDeviceTableMaster.RegistrationNumber;
        printLabelKeyTag.Colour                     = amDeviceTableMaster.ExteriorId;
        printLabelKeyTag.BrandId                    = amDeviceTableMaster.BrandId;
        printLabelKeyTag.ClassId                    = amRentDevice.ClassId;
        printLabelKeyTag.HERSnowSock                = amDeviceTableMaster.HERSnowSock;
        printLabelKeyTag.insert();
        ttscommit;
    }
    public void setTableConnections()
    {
        printLabelKeyTag.setConnection(this.parmUserConnection());
    }
    /// <summary>
    /// Process report data.
    /// </summary>
    public void processReport()
    {
        AMDeviceTable                       amdeviceTable;
        List                                list = new List(Types::String);
        Query                               queryDeviceId;
        QueryRun                            queryRunDeviceId;
        QueryBuildDataSource                qbdsDeviceId;
        ListIterator                        deviceIdListIterator;
        contract = this.parmDataContract() as HERPrintLabelKeyTagContract;
        list = contract.parmDeviceId();
        if(list != null)
        {
            deviceIdListIterator = new ListIterator(list);
            queryDeviceId = new Query(queryStr(HERPrintLabelKeyTag));
            qbdsDeviceId = queryDeviceId.dataSourceTable(tableNum(AMDeviceTable));
            
            while(deviceIdListIterator.more())
            {
                //qbdsDeviceId.clearRanges();
                qbdsDeviceId.addRange(fieldNum(AMDeviceTable, DeviceId)).value(deviceIdListIterator.value());
                deviceIdListIterator.next();
            }
            queryRunDeviceId = new QueryRun(queryDeviceId);
            while(queryRunDeviceId.next())
            {
                amdeviceTable = queryRunDeviceId.get(tableNum(AMDeviceTable));
                this.insertTmpTable(amdeviceTable.deviceId);
            }
        }
    }
}
  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    Print multiple records using SSRS report
    If you tested that your RDP class returns the right records, than the code above isn't relevant, because the problem isn't there. It's in your report. Please tell us more about it. A suspicious thing is that you said you used a static field instead of a tablix linked to your data source.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans