Create a View to display data for current user

I would like to create a view that limits the list of opportunities to only those that the current user is working on OR opportunities that are closed (won, lost, dead). I copied vListOpportunities and added the oppo_status criteria, however I have not found anything that works within a view for the current user.
I have tried:

  • oppo_assigneduserid = CurrentUser.user_userid
  • oppo_assigneduserid = #U
  • oppo_assigneduserid = CurrentUser
  • oppo_assigneduserid = User_userid

Both, when I do and do not have User.* to the parameters, it give a SQL error. Is this possible?

  • 0

    Hi Stephanie,

    I have tried this also, and I don't seem to get an error, both when I run vListOpportunity (with the same amendments you made) as a query in SQL, or if I update vListOpportunity in CRM under Administration > Customisation > Opportunity > Views.

    Here is my updated version of vListOpportunity:

    SELECT RTRIM(ISNULL(Pers_FirstName, '')) + ' ' + RTRIM(ISNULL(Pers_LastName, '')) AS Pers_FullName, Pers_PersonId, Pers_CreatedBy, Pers_SecTerr, Pers_PrimaryUserId, Pers_ChannelID,

    epd_pers.epd_EmailAddress as Pers_EmailAddress, Comp_Name, Comp_CompanyId, Comp_CreatedBy, Comp_SecTerr, Comp_PrimaryUserId, Comp_ChannelID, Chan_ChannelId, Chan_Description,

    epd_comp.epd_EmailAddress as Comp_EmailAddress, Opportunity.*, (COALESCE(Oppo_Forecast, 0) * COALESCE(Oppo_Certainty, 0)) / 100 AS Oppo_Weighted, Users.*

    FROM Opportunity

    LEFT JOIN Person ON Pers_PersonId = Oppo_PrimaryPersonId

    LEFT JOIN CRMEmailPhoneData epd_pers ON epd_pers.epd_EntityID = 13 AND epd_pers.epd_RecordID = Pers_PersonID

    LEFT JOIN Company ON Comp_CompanyId = Oppo_PrimaryCompanyId AND Comp_Deleted IS NULL

    LEFT JOIN CRMEmailPhoneData epd_comp ON epd_comp.epd_EntityID = 5 AND epd_comp.epd_RecordID = Comp_CompanyID

    LEFT JOIN Channel ON Oppo_ChannelId = Chan_ChannelId

    LEFT JOIN Users on Oppo_AssignedUserId = user_userid

    WHERE Oppo_Deleted IS NULL and oppo_status = 'Won'

    I have added Users.* in the SELECT statement, and added a Left Join to the Users table. I also added in oppo_status into the WHERE clause, and it allowed me to save without any errors. Is your view similar to this?

    Thanks,

    Ben

  • 0

    Ben,

    Not sure what I was overlooking, but this does work. (with me it's usually punctuation)

    Thank you so much!

    Stephanie