How to Add Additional Data to a Query Based Report
You can take a classic SSRS approach to add additional data to a SSRS query-based report, which means extending the report query as described in MS documentation.
However, there is another so-called Docentric approach, by using a custom DSP class. However, there is a difference between adding additional data to RDP- (Report Data Provider) based reports and query-based reports.
Namely, you need to override the addAdditionalDataFieldsForQueryRecord() method instead of the addDataFieldsForRdpTableRecord() method which is used for RDP-based reports.
Another difference is that when adding additional data via the addAdditionalDataFieldsForQueryRecord() method, there is no option to remove fields you don’t need.
Let’s take a look at Work report (WHSWork.Report) and how we can add additional data using Docentric approach.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | protected void addAdditionalDataFieldsForQueryRecord(DocXmlRecord _addingRecord,                                                      Common _common, QueryBuildDataSource _qbds) { 	super(_addingRecord, _common, _qbds); 	if (tableNum(WHSWorkTable) == _qbds.table()) 	{ 		// TODO: Add here additional fields related to WHSWorkTable, for example CustomerName. 		WHSWorkTable workTable = _common; 		if (workTable.WorkTransType == WHSWorkTransType::Sales) 		{ 			SalesTable salesTable = SalesTable::find(workTable.OrderNum); 			_addingRecord.addCalculatedField('CustomerName', salesTable.customerName()); 		} 		else if (!this.isRuntime()) 		{ 			// It's not applicable but we'll add it if this executes when DDSP is being produced 			// to maintain the uniform data schema. 			_addingRecord.addCalculatedField('CustomerName', ''); 		}    	} 	else if (tableNum(WHSWorkLine) == _qbds.table()) 	{ 	    // Add the display method for showing item name of the line     		_addingRecord.addDisplayMethod(tableMethodStr(WHSWorkLine, displayItemName)); 		// TODO: Add here additional fields related to WHSWorkLine. 	} } | 
See also
Data Source Generation Options Specifics for Query-Based Reports >>
Example: Query-Based Report Customization >>
Training Lab: Query-Based Report Customization >>
How to Add Additional Data to a Docentric SSRS Report >>