Skip to Content Skip to Menu

How to set a field based on a query with an auto action?

  • fkrauth
  • fkrauth
  • OFFLINE
  • Posts: 45
  • Thanks: 7
  • Karma: 2
2 years 4 months ago #330133 by fkrauth
Hi!
I would like to update a custom CB field based on a select query with an auto action. But I don't know how to use the result of the select (e.g. a date) in the field-action.

Could you please give me some hints how to proceed? Can I store the result of the query in a variable and use it to fill the field?

Thanks a lot!

Frank

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 4 months ago #330134 by krileon
A query select field should already be stored in the database so you shouldn't need to store it twice. If you want to display it in a Custom HTML field you'd just substitute it in as shown in our substitution tutorial below.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb

Aside from that am unsure what you're asking. Are you wanting to update Field A while conditioning against Field B with Field B being your query select?


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.

  • fkrauth
  • fkrauth
  • OFFLINE
  • Posts: 45
  • Thanks: 7
  • Karma: 2
2 years 4 months ago #330135 by fkrauth
Hi!
Thanks for your quick reply.
The select is not on a field but I need to select a specific date for each user with a bit more complex statement with joins over a couple of tables.
That date I would like to store into a field and show it in CB to the user. I also want to store it in order to reuse the field for other purposes.

Thanks!

Best,
Frank

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 4 months ago #330137 by krileon
So you need to set a fields value with the result of custom code or custom SQL? If SQL you should be able to use a Query action and directly update _comprofiler table. If code then a Code action with Method set to PHP can be used to set values on $user then $user->store() it to save the values.

The field action has no support for setting a field based off a custom SQL unless you create a Query fieldtype, add your SQL there, then substitute it into the auto action to be stored into a field.

This brings up the question of does this really need stored in the database? For example does it need to be searchable? If not it maybe better to just use a Query field and query for whatever information in your other tables that you're needing.


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