[SOLVED] Setting a value in another component

4 years 6 months ago - 4 years 5 months ago #314983 by ericmuc
Hi,
I have a check-box field in CB. If this check-box field is set to yes, a field of another component in Joomla shall set to "1".
I would like to create an autoaction with "onAfterUpdateUser" and conditions cb_field Equal To "yes" and ... here I have no clue, how to proceed to set an value in another field in the mysql data bank.
Can you give me a hint?
Thanks a lot, best regards

Please Log in to join the conversation.

4 years 5 months ago #314989 by krileon
Replied by krileon on topic Setting a value in another component
Checkbox fields have a value of 1 (yes) or 0 (no) or NULL (no). It's best to condition Equal To or Not Equal To 1 for accuracy. So to condition against your checkbox field in your auto action you'd have something like the below.

Checked
[FIELD_NAME] Equal To 1

Not Checked
[FIELD_NAME] Not Equal To 1

As far as pushing data to a 3rd party extension we can't help you there. If it's in the database you'd use a Query action and have to write the necessary SQL to do that. If it has an API you can use you'd use a Code action so you can write the necessary PHP to do that.


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.

4 years 5 months ago #314990 by ericmuc
Replied by ericmuc on topic Setting a value in another component
Thanks, ok, I understand, but I am not sure, how I shall use autoaction.

I set up an autoaction with code, the add with jquery for example "UPDATE 'xxx_djcf_profiles' SET 'verified' = '1' WHERE 'user_id' = '894' and output on return. I tried already php with something like
<?php
//Verbindung zur Datenbank herstellen
mysql_query("UPDATE kunden SET name = 'Donald Duck', adresse = 'Entenhausen' WHERE name = 'Emil Entenich'");
?>
Nothing is working.
So I need now the next step in using autoaction.
Could you please advice?
Thanks, best regards

Please Log in to join the conversation.

4 years 5 months ago #314995 by krileon
Replied by krileon on topic Setting a value in another component
You don't use PHP tags in a Code action. Just put your PHP code in it only. You also don't use MySQL functions directly and need to use Joomla or CB API to execute a query. You also don't need a Code action for that and can just directly put your SQL in a Query action (it's not jQuery) it self. I can not help you write database queries for 3rd party extensions. I've no clue what their database structure is or what data it expects. Using your supplied queries for example you'd have the below Query action.

Action
Triggers: onAfterUserUpdate, onAfterUpdateUser (this covers frontend and backend profile edit)
Type: Query
User: Automatic
Access: Everybody
Conditions
1: [FIELD_NAME] Equal To 1
Action
Query:
UPDATE `#__djcf_profiles` SET `verified` = 1 WHERE `user_id` = '[user_id]'

Recommend the below resources to get started learning SQL.

Documentation
dev.mysql.com/doc/refman/5.7/en/entering-queries.html
dev.mysql.com/doc/refman/5.7/en/examples.html
dev.mysql.com/doc/refman/5.7/en/functions.html

Free Lessons
www.codecademy.com/learn/learn-sql
www.khanacademy.org/computing/computer-programming/sql
sqlbolt.com/
www.udemy.com/topic/sql/free/


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.

4 years 5 months ago #315002 by ericmuc
Replied by ericmuc on topic Setting a value in another component
Thanks, I started with the wrong autoaction type, so with your suggestion I could get it running now! Great.
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

4 years 5 months ago #315018 by ericmuc
Replied by ericmuc on topic Setting a value in another component
One further question to this:
in backend in autoactions the column "Uses" shows "0" in spite of being used already. How I have to interpret this number?
Thanks, best regards

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.194 seconds

Facebook Twitter LinkedIn