Using CB Substitution within Query field

4 years 3 months ago - 4 years 3 months ago #316227 by wbuk
We are wondering if you could tell us why this isn't working. We have a Query Drop Down (Single Select) field called cb_class. Within its Query Parameter, we have:
SELECT DISTINCT `cb_class` FROM `wbedu_comprofiler` WHERE `cb_school` = '[cb:userdata field="cb_school" user="#displayed" /]'

Nothing shows in the dropdown. But if query changed to:
SELECT DISTINCT `cb_class` FROM `wbedu_comprofiler` WHERE `cb_school` = 'Demo School'

or
SELECT DISTINCT `cb_class` FROM `wbedu_comprofiler` WHERE `cb_school` = '[cb:userdata field="cb_school" user="#me" /]'


It works fine. If [cb:userdata field="cb_school" user="#displayed" /] is put anywhere else, it displays Demo School. So we are not sure why the first query isn't working?

Web Buster UK Ltd

Please Log in to join the conversation.

4 years 3 months ago #316228 by wbuk
Replied by wbuk on topic Using CB Substitution within Query field
Scratch that. We could have used the substitution [cb:userfield field="cb_school" /] which worked perfectly.

Web Buster UK Ltd

Please Log in to join the conversation.

4 years 3 months ago #316238 by krileon
Replied by krileon on topic Using CB Substitution within Query field
#displayed is a special user parameter value for substitutions. It only applies to profile view. It's not set anywhere else. So using it outside of profiles for example will not work. In most cases however it shouldn't be necessary as for example all fields substitutions always use the profile owner as the substitution source so just using substitutions without the user parameter will give you the expected result.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.190 seconds

Facebook Twitter LinkedIn