web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get current record accountid value for SSRS report

(0) ShareShare
ReportReport
Posted on by

Hello,

I would like to know how to gather the current accountid for an SSRS report. I'm currently replicating the functionality of an existing report at the Account level, currently the user can generate the report from a button in the Opportunity.  

The dsOpportunity dataset query type for the Opportunity looks like this;

select
Oppty.OpportunityId as [OpptyId],
getdate() as [EffectiveDate],
Acct.Name as [AccountName],
Acct.aep_UtilityAccountNumber as [AccountNumber],
Acct.Address2_Line1 as [AddressLine1],
Acct.Address2_Line2 as [AddressLine2],
Acct.Address2_Line3 as [AddressLine3],
Acct.Address2_City as [City],
Acct.Address2_StateOrProvince as [State],
Acct.Address2_PostalCode as [ZipCode],
SystemUser.FullName as UserFullName,
SystemUser.JobTitle as UserJobTitle,
Contact.FullName as ContactFullName,
Contact.JobTitle as ContactJobTitle

from FilteredOpportunity as Oppty with (nolock)
inner join FilteredAccount as Acct with (nolock) on Oppty.ParentAccountId = Acct.AccountId
inner join FilteredSystemUser as SystemUser with (nolock) on Oppty.OwnerId = SystemUser.SystemUserId
left join FilteredContact as Contact with (nolock) on Acct.PrimaryContactId = Contact.ContactId

where Oppty.OpportunityId = @OpportunityId

3113.Capture2.jpg

The report contains the OpportunityID parameter with a default value, however when I run it from the Opportunity it returns the information of the record on focus.

I added a new AccountID parameter similar to the OpportunityId paramenter and added a new dsAccount dataset, 

SELECT name AS Company
FROM FilteredAccount
WHERE accountid = @AccountId

For some reason, it always pickup the default value I assigned on the report instead of the current account on focus. 

I would appreciate anybody that can shed some light on this topic, i.e. what I am missing out, why this work for the opportunity and not for the account.

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: Get current record accountid value for SSRS report

    the entity id was being passed to the report on the url, I was able to use it in other record types where I placed the button.

    GET /AgreementViewer.ashx?id={7CD3B837-D86C-E411-80CF-6A65002F517C}&attachment=false&export=pdf&docs=91754bcc-f233-e411-80cb-6a65002f517c HTTP/1.1

  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans