Using CB Substitution within Query field

1 week 4 days ago - 1 week 4 days 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'

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
1 week 4 days ago #316228 by wbuk
Scratch that. We could have used the substitution [cb:userfield field="cb_school" /] which worked perfectly.

Web Buster UK Ltd
1 week 4 days ago #316238 by krileon
#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 - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
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 EST to 4:00 PM EST. 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.
Moderators: beatnantkrileon
Time to create page: 0.412 seconds

Facebook Twitter LinkedIn