Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsAdd custom profile field to SQL queryAdd custom profile field to SQL query
Previous
 
Next
New Post
2/8/2009 11:36 AM
 

Hello,

I want to use the Report module in combination with the Events module. I hardly know anything about SQL, but I need to display a custom created profile field using the Reports module. I've added a profile field called "Bedrijfsnaam". But I can't get it to display in the report. I've tried the following:

 

SELECT

Users.Bedrijfsnaam AS [Bedrijfsnaam], Users.FirstName AS [First Name], Users.LastName AS [Last Name], Users.Email AS [E-Mail]

FROM

EventsSignups INNER JOIN
Events

ON EventsSignups.EventID = Events.EventID INNER JOIN
Users

ON EventsSignups.UserID = Users.UserID
ORDER

BY LastName DESC

 

That gave me an error. It works fine if I remove "Users.Bedrijfsnaam AS [Bedrijfsnaam], " Can anyone tell me how I can achieve this?
Thanks in advance.

 
New Post
2/8/2009 2:32 PM
 

The custom profile property that you created is not in the USERS table.  You will need to dig into the Profile, Profile Properties, and UserProfile tables to construct the query that you will need to get the data.

There is a bit of indirection in here so that profile properties can be created and added to the profiles without changing the table structures.




Joe Craig
Patapsco Research Group, Ellicott City, MD
DotNetNuke Development and Services (http://patapscorg.com)
 
New Post
2/10/2009 4:30 AM
 

I actually found how to do it. For anyone else who's interested, see below:

SELECT

(Select UP.PropertyValue From UserProfile UP Where Users.UserID = UP.UserID And UP.PropertyDefinitionID = 61) As [Bedrijfsnaam]

etc.

You can find out which PropertyDefinitionID you need with this query (change PortalID if necessary):

SELECT DISTINCT PortalID, PropertyDefinitionID, PropertyName
FROM ProfilePropertyDefinition
WHERE (PortalID = 0)
ORDER BY PropertyDefinitionID

 
New Post
3/12/2009 6:42 PM
 

How could I contruct that into a full query to use? For instance if I were wanting to find out what volleyball team a user was in from a custom profile field in DNN. I'm new to SQL but I understand the concept of joins and how to do them somewhat. Any guidance is greatly appreciated!

 
New Post
10/9/2009 3:08 AM
 

I built a query that includes a couple of custom profile fields, using ideas I gleaned from several different posts.  This is the result; hope it helps someone.

SELECT
  u.LastName AS [Last Name],
  u.FirstName AS [First],
  r.Rolename AS Type,
  CONVERT(VARCHAR, ur.EffectiveDate,1) AS Joined,
  CONVERT(VARCHAR,ur.ExpiryDate,1) AS Expires,
  upd.DOB,
  upd.Phone,
  u.Email
FROM dbo.Users as u INNER JOIN
  dbo.UserRoles AS ur ON u.UserID = ur.UserID  INNER JOIN
  dbo.Roles AS r ON ur.RoleID = r.RoleID
    LEFT OUTER JOIN
  (SELECT      
    up.UserID,  
    MAX(CASE WHEN ppd.PropertyName = 'DateOfBirth' THEN up.PropertyValue ELSE '' END) AS DOB,
    MAX(CASE WHEN ppd.PropertyName = 'Telephone' THEN up.PropertyValue ELSE '' END) AS Phone
   FROM           
    dbo.UserProfile AS up INNER JOIN 
    dbo.ProfilePropertyDefinition AS ppd ON up.PropertyDefinitionID = ppd.PropertyDefinitionID AND ppd.PortalID = 0 
   GROUP BY up.UserID) AS upd ON u.UserID = upd.UserID 
ORDER BY CAST(u.Lastname as varchar(3)) ASC

William

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsReportsReportsAdd custom profile field to SQL queryAdd custom profile field to SQL query


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out