CurrentUser Memberships

Delford Chaffin asked on June 2, 2014 17:22

Can anyone explain the following output of these 3 different macros:

<div>:::{%CurrentUser.HasMembership("SAA-Colorado")#%}</div>
<div>:::{%CurrentUser.Memberships.Count#%}</div>
<div>:::{%CurrentUser.GetProperty("Memberships", "---").Count#%}</div>

---- outputs:

:::True
:::0
:::0

The first returns "True" and would seem to (properly) indicate that the user has this membership, but the latter two attempts to get the count of said memberships always returns 0.

Ultimately what I need to do is use this in the where clause of a query and say something like:

WHERE SAA IN ({%CurrentUser.Memberships#%}) // where I end up with a comma-separated list

Thanks!

Recent Answers


Delford Chaffin answered on June 3, 2014 10:58 (last edited on December 10, 2019 02:30)

Since none of the above worked, I ended up using this WHERE clause:

SAA IN ( 
  SELECT MembershipDisplayName
  FROM View_Membership_MembershipUser_Joined
  WHERE UserID = {%CurrentUser.UserID|(identity)GlobalAdministrator%}
)
0 votesVote for this answer Mark as a Correct answer

Martin Danko answered on November 24, 2014 13:39 (last edited on December 10, 2019 02:30)

Hello Delford,

I was able to reproduce this behavior and have checked it with our development team. Regrettably, this is not a bug but behavior caused by the design of application.

In this scenario, the following 2 namespaces come into the game: CMS.Membership vs OM.Membership

The macro engine removes the prefixes and therefore it returns a completely different collection that you are expecting as it's related to On-line marketing.

In this case the following macro will work: {% CurrentUser.OtherBindings.MembershipUsers.Count |(identity)GlobalAdministrator%}

Best regards, Martin

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.