Skip to Content Skip to Menu

CB Query field

  • jcasey
  • jcasey
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
9 years 11 months ago #253739 by jcasey
CB Query field was created by jcasey
Hi,
I need text field contain membership status from AEC database.

I tried following steps,

Step 1

Type = Query
Name = cb_Status
Title = Status

Query = SELECT `status` FROM `#__acctexp_subscr` WHERE `userid` = '[user_id]'
Query Mode = Internal

Results Output = Single Row
Results Columns = Single Column

Location Registration = Disabled
Location Profile Edit = Disabled
Location Profile View = Enabled
Location Userlists View = Enabled

Step 1 Result
Field not available on backend and frontend profile view

I need to set the result as default value inside cb_status field.
Any idea what i'm missing...


Step 2

Type = Query Drop Down (Single Select)
Name = cb_Status1
Title = Status1

Query = SELECT `status` FROM `#__acctexp_subscr` WHERE `userid` = '[user_id]'
Query Mode = Internal

Options Value Column = user_id
Options Label Column = Membership Status
Options Group Column = blank

Step 2 Result
Its success and The field is visible with correct data inside dropdownlist

I need to set the result as selected value inside cb_statu1 field instead drop down list.

Thanks in Advance

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48495
  • Thanks: 8284
  • Karma: 1443
9 years 11 months ago #253792 by krileon
Replied by krileon on topic CB Query field
The standard query field just queries the database and outputs the result of the query. It doesn't do anything beyond that. If your query is going to result in multiple rows then be sure you limit it to 1 result with LIMIT 1 unless using a multiple row display.

Test your raw query on phpmyadmin for expected results. Also check if you're conditioning your query field with CB Conditional or disabling its output with CB Privacy. What kind of value are you expecting it to output? String? Integer? Date?


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 or Create an account to join the conversation.

  • jcasey
  • jcasey
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
9 years 11 months ago #254675 by jcasey
Replied by jcasey on topic CB Query field
Hi,
The option2 it works fine.
The result populate from database and the drop down list shows the fields

e.g.

result1
result2
result3

But i need one of this field as selected by default on drop down list.
Im trying to save additional field to cb from another database.

Best Regards,
Firdous

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48495
  • Thanks: 8284
  • Karma: 1443
9 years 11 months ago #254724 by krileon
Replied by krileon on topic CB Query field

But i need one of this field as selected by default on drop down list.

You need to use the "Default Registration Value" parameter when editing your field to have a default value pre-selected. Note this only works at registration. The alternative is to adjust the ORDER BY of your query and try to force the value you want pre-selected to be the first value of the field.

Im trying to save additional field to cb from another database.

Then you may want to use CB Auto Actions and just keep the two databases in sync. CB Query Field just outputs the results of the query. It does not save anything. The query select field of course saves, but only if the user registers with something selected or updates their profile with something selected as the query select fields are just populating a select with options.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum