SSRS reports dynamics crm have current record id used as parameter - dynamics-crm

Hi for my ssrs report In dynamics crm I require that when the report is ran against a certain record, the records passes the record id so that only the relevant results are displayed.
How is this possible ? Steps provided will be great also
Reports are created using SQL.
Run against campaign entity

SSRS reports for CRM have special parameters that enable this for you. To filter by selected records (or the current record you have open) you can utilise a hidden parameter called "CRM_Filtered[Entity]" where entity is the relevant entity you are linking the report to.
In your case, i.e. for the campaign entity, this hidden parameter will be called CRM_FilteredCampaign. For a SQL report this will be a text parameter and will be set to something like this (set by CRM when you run the report)
select campaign0.* from FilteredCampaign as "campaign0"
I do not have a report to hand to check exactly what the SQL will contain, so it might not be exact. But you get the idea. There are several ways to embed this in your report, but you could do so in a rudimentary fashion like this in a dataset:
declare #sql as nVarchar(max)
set #sql = 'SELECT c.campaignid FROM (' + #CRM_FilteredCampaign + ') as c'
exec(#sql)
Expanding on this, i.e. rather than executing text SQL in your main dataset, you can instead simplify the usage by creating a dataset/parameter combo based off the text. In effect, convert the SQL text to a list of values instead.
So add the above SQL to its own DataSet (for this example called DS_FilteredCampaign).
Once you have created DS_FilteredCampaign make sure you click on the Refresh Fields button. Type in the following instead of <null> for the parameter value:
select c.* from FilteredCampaign as c
Once that comes back click on Ok to save the DataSet.
Next, create another hidden text parameter (e.g. Int_FilteredCampaign) and tell it to get its default value from a DataSet (not its available values, its default value). Point the values at DS_FilteredCampaign, and you should be able to select campaignid as its value field. This in effect makes the parameter an array of Ids you can reference in your main DataSet
Now it's much more usable as you can reference it in your SQL something like this in your main DataSet:
select c.*
from FilteredCampaign c
inner join ActivityPointer ap on ...
inner join FilteredAccount a on ...
where c.campaignid in (#Int_FilteredCampaign)
The important piece being where c.campaignid in (#Int_FilteredCampaign)
Summary Steps:
You have a main DataSet called something like dsMain
Create a new parameter called CRM_FiltetedCampaign
Create a DataSet (DS_FilteredCampaign) that executes the SQL passed into CRM_FilteredCampaign
Refresh Fields on the data set to get the campaignid field
Create a text parameter (Int_FilteredCampaign) that retrieves its default value using the new dataset (DS_FilteredCampaign) using campaignid for the value
Reference this new parameter in you dsMain dataset

Related

Can I use expression builder to return a SQL query result to a variable?

I am using a software, pc/mrp, which appears to have a built-in Visual Fox Pro editor for FRX files. It also has an external usage of an ef file. Based on some usage of Google, the report designer seems standard, not custom. The ef file usage may be a custom thing. Now, I need to find a way to get access to a value from a SQL statement inside the report. The statement needs to run per-line in the report.
EF:
This file has sections:
~in~
~out~
In these sections, I can run code, but if there is a ~perline~ type section, I don't know how to access it. I can use the ~in~ to try to create a relationship between the databases, as shown in the following example:
~IN~
THISAREA = SELECT()
USE PARTMAST ORDER BYPARTNO IN 0
SELECT (THISAREA)
SET RELATION TO PARTNO INTO PARTMAST ADDITIVE
GO TOP
~OUT~
USE IN SELECT("SALES")
But, for this I don't know how to join the databases. I have two databases (A,B) I need to connect them based on two fields (pono,line). If (A.pono and a.line) = (B.pono and B.line) then they would be linked. Is this possible?
Report Designer:
The other way I see this working is to do the query inside the report designer. Inside report properties is a variable tab. I can use this to assign to variables using expressions. I need:
SELECT field from B where B.pono = pono and B.line = line; INTO ARRAY varArray;
But, it gives me an error, likely because this is trying to create a new variable as opposed to actually assigning to the variable in the report. I tried editing a field inside the designer to use the preceeding code as well, but that also failed.
Is there a way using the report designer or the ef file to grab the data I need per line?
The sample code you show is doing something like a join with the SET RELATION command. To use SET RELATION, there has to be an index on the relevant field (expression) in the child table. So, if your table B has an index on PONO + LINE (or, if those are numeric, STR(PONO, length) + STR(LINE, length)), you can SET RELATION TO PONO + LINE INTO B, again, using the more complicated expression if necessary.

How to use bind variable in oracle report parameter form?

I have a parameter form with a value for the fiscal year and equipment ID. I want to populate the equipment ID list of values based on the fiscal year that is selected.
My query for the equipment ID list of values would be
SELECT EQPID,NAME FROM EQPLIST WHERE FY = :FY.
When I tried to add this query to the list of values of the equipment ID parameter I get
REP-0781: Bind variables are not allowed in the Select statement.
Is there a way to dynamically generate the list of values select statement in a reports trigger?
Cascading LoV, eh?
Which Reports version do you use? If it is 6i (client-server), I believe that your only resort is to create a parameter form using Oracle Forms, and then pass those parameters to a report.
If you're on a higher version (web-based), have a look at Metalink note 185951.1 ("How to create a parameter LOV based on another parameter value?") which includes sample code. Or, as above, create your own parameter form in Forms (that option works in any version).

Trying to generate SSRS report based on input parameters in visual studio

I have an AX query dataset that I'm trying to use to generate an SSRS report. I want to the user to be able to enter 2 parameters (Date and ProjectId) and have the SSRS report return a table based on the query using the parameters inputted by the user. Can't write any code so it needs to be purely graphical.
You can simply add your parameters to query as query ranges.
In the AOT, click Queries, and locate the query that you want to define a range for.
Expand the query, click Data Sources, and then expand a data source.
Right-click Ranges, and then click New Range.
Right-click the new range, click Properties, and then select a field in the Field property list.
Type an expression in the Value property to specify which records are retrieved.
here it's a helpful link for creating queries with ranges:
https://msdn.microsoft.com/en-us/library/bb314753.aspx
Here is a walkthrough to follow:
https://technet.microsoft.com/en-us/library/cc636713.aspx

Using variables in From part of a task flow source

Is there any way to use a variable in the from part (for example SELECT myColumn1 FROM ?) in a task flow - source without having to give the variable a valid default value first?
To be more exact in my situation it is so that I'm getting the tablenames out of a table and then use a control workflow to foreach over the list of tablenames and then call a workflow from within that then gets data from these tables each. In this workflow I have the before mentioned SELECT statement.
To get it to work properly I had to set the variable to a valid default value (on package level) as else I could not create the workflow itself (as the datasource couldn't be created as the select was invalid without the default value).
So my question here is: Is there any workaround possible in this case where I don't need a valid default value for the variable?
The datatables:
The different tables which are selected in the dataflow have the exact same tables in terms of columns (thus which columns, naming of columns and datatypes of columns). Only the data inside of them is different (thus its data for customer A, customer B,....).
You're in luck as this is a trivial thing to implement with SSIS.
The base problem for most people is that they come at SSIS like it's still DTS where you could do whatever you want inside a data flow. They threw out the extreme flexibility with DTS in favor of raw processing performance.
You cannot parameterize the table in a SQL statement. It's simply not allowed.
Instead, the approach that people take is to use Expressions. In your case, assuming you had two Variables of type String created, #[User::QualifiedTableName] and #[User::QuerySource]
Assume that [dbo].[spt_values] is assigned to QualifiedTableName. As you loop through the table names, you will assign the value into this variable.
The "trick" is to apply an expression to the #[User::QuerySource]. Make the expression
"SELECT T.* FROM " + #[User::QualifiedTableName] + " AS T;"
This allows you to change out your table name whenever the value of the other variable changes.
In your data flow, you will change your OLE DB Source to be driven by a query contained in a variable instead of the traditional table selection.
If you want an example of where I use QuerySource to drive a data flow, there's an example on mixing an integer and string in an ssis derived column
Create a second variable. Set its Expression to create the full
Select statement, using the value of the first variable.
In the Data Source, use "SQL command from variable" option for the
Data Access Mode property.
If you can, set a default value for the variable you created in step
That will make filling out the columns from your data source much easier.
If you can't use a default value for the variable, set the Data
Source's ValidateExternalMetadata property to False.
You may have to open the data source with the Advanced Editor and
create Output columns manually.

How to pass parameters to data set behind a data cube in BIRT?

I have a data cube which is based on a data set. The data set takes a number of parameters. So far I have not been able to find out how to pass parameters to that data set. I see that it is possible to set a filter on the data cube but that doesn't help me.
How can I pass the necessary parameters to the data set?
To pass parameters to a relational data source in BIRT:
Set up appropriate Report Parameters (via the Data Explorer).
Add parameter markers (ie. ?s) to your SQL query where you want to parameterise the query (eg. if you want to select customers by country, change your datasource query to be SELECT * FROM CUSTOMER WHERE COUNTRY = ? ).
Add dataset parameters to your dataset (via the Parameters tab of the Edit Data Set dialog) in the order they appear in your SQL query, and specify the corresponding Report Parameter in the Linked to Report Parameter value of the New Parameter dialog. (This is how you manually bind the Report Parameters to the parameters in the query - you will need to set up a dataset parameter for each parameter marker in the SQL query.)
If you now preview the report, it should prompt you for parameter values and then display the report (appropriately filtered).
If you were using a non-relational data source, you would set up a filter at the dataset level instead of parameterising the query - there is an example of this approach here. (You can do this with SQL-based reports too, but it is less efficient than filtering at the query level.)

Resources