Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 9244

How to create a context sensitive report using a Stored procedure that accepts one field from the Filteredentity ?

$
0
0

I need to create an Account specific report in CRM 2011 which shows the results from a stored procedure that is set to accept the UniqueId value from the FilteredAccount entity.

So what I expect the report to do when a user runs the report from an Account -

1. Get the UniqueId field value of this Account (using the CRM FilteredAccount view)

2. Pass this value to the stored procedure

3. Execute the Stored Procedure with that value

4. Display the results (set of columns) in the report.

Note - The Stored procedure is located on a different database [CRM_Data] on the same server as the CRM database is.

The stored procedure works perfectly with a string input when run from the SQL Server Management Studio(SSMS).

I have designed the SSRS report in the following way :

1. Add a parameter( CRM_FilteredAccount)

   Default value -> Specify values -> select *from [FilteredAccount]

2. Add a datasource (connecting to the CRM database)

3. Add a dataset with

Query Type : Text and Query as follows:

DECLARE @sqlCommand  NVARCHAR(1000)
DECLARE @UniqueId NVARCHAR(50)

SET @sqlCommand = 'SELECT @MyUniqueId = [directorycode] FROM ('+ @CRM_FilteredAccount +') t'

EXECUTE sp_executesql @sqlCommand, N'@MyUniqueId NVARCHAR(50) output', @MyUniqueId = @UniqueId  output

EXEC [CRM_Data].[dbo].[proc_Usage_PerUniqueId] @UniqueId

With this report ready, I have uploaded it into the CRM and set it to appear on all Account type of entities. The report doesnt work sadly.

Could you point out what is going wrong?

Let me know if any further information is required.

Cheers!

Shiny


Viewing all articles
Browse latest Browse all 9244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>