Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

CB Auto Actions tutorial for integer sum field

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
9 years 11 months ago #256134 by nant
CB Auto Actions Tutorial #04.
Creating and maintaining a CB Integer Sum field using a field action or a query action.

www.youtube.com/playlist?list=PLp0puRITgC7McQcw0Sli1qfSUQGwmflzi

Resources used:

CB 2.0.4
CB Auto Actions 6.1.1+

Logic behind conditional tab:

[var3_cb_score1][var3_cb_score2] Not Equal To [var1_cb_score1][var1_cb_score2]

e.g., if score 1 is updated from 1 to 2 and score 2 is updated from 10 to 11
then this condition evaluates to:

110 Not Equal To 211

and the auto-action will be executed

But !!! what if: score 1 is updated from 31 to 3 and score 2 from 3 to 15
then the condition becomes:

315 Not Equal To 315

WHICH IS NOT WHAT WE WANT!

So, we just add a separator character (e.g., !)

[var3_cb_score1]![var3_cb_score2] Not Equal To [var1_cb_score1]![var1_cb_score2]

and this way our previously failing condition will now evaluate to:

31!5 Not Equal To 3!15

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

  • boyjahq
  • boyjahq
  • OFFLINE
  • Posts: 473
  • Thanks: 33
  • Karma: 3
6 years 9 months ago #302564 by boyjahq
This is confusing! Wouldn't score 1 give 313 and score 2 give 315?

But !!! what if: score 1 is updated from 31 to 3 and score 2 from 3 to 15
then the condition becomes:

315 Not Equal To 315

Shouldn't it be "score 1 is updated from 31 to 5 and score 2 from 3 to 15"?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
6 years 9 months ago #302629 by krileon
It's just taking 2 fields and stacking them next to each other. It then compares the old fields to the new fields to see if the value changed. If it did the action triggers. If it didn't then the action is skipped. Example as follows.

Field 1 = 10
Field 2 = 11

[cb_field1][cb_field2] = 1011

The above tutorial is making sure you add a separator since we're dealing with integers and you don't want odd conflicts to happen. So we'd add a separator to my above example as follows.

[cb_field1]![cb_field2] = 10!11

Below is an example of how without a separator things can go wrong.

Old Field 1 = 11
Old Field 2 = 1
[cb_field1][cb_field2] = 111

New Field 1 = 1
New Field 2 = 11
[cb_field1][cb_field2] = 111

The new values swapped field 1 and 2. This causes the combined values to be 111. Same as the old value. So if you compare the old and new they're equal. This doesn't happen with a separator as follows.

Old Field 1 = 11
Old Field 2 = 1
[cb_field1]![cb_field2] = 11!1

New Field 1 = 1
New Field 2 = 11
[cb_field1]![cb_field2] = 1!11

Those are not the same so the action will trigger. This is really only necessary when dealing with combined integer conditions. You have to do things this was because there's no OR conditions in CB Auto Actions yet.


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.
The following user(s) said Thank You: nant

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

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
6 years 9 months ago #302657 by MMDoege
Was assuming when using multiple conditions (more than 1 row of conditions) in auto action there's an OR operator between each row of conditions.
Hence meaning: execute auto action when at least one of conditions provided is true. Am I right?

Is condition concatination then the methode to build AND conditions, like
[cb_field1]![cb_field2] EQUAL TO 1!""
(objective: execute action when cb_field1 is true AND cb_field2 is EMPTY)?

And if all of the above is wrong: how would I build multiple conditions with AND operator between them for the same auto action?

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

  • boyjahq
  • boyjahq
  • OFFLINE
  • Posts: 473
  • Thanks: 33
  • Karma: 3
6 years 9 months ago #302659 by boyjahq
I understand the point of the tutorial. I am saying that the example given, both in the video and in the original post above, is wrong and therefore confusing and misleading.

Where it says:
"what if: score 1 is updated from 31 to 3 and score 2 from 3 to 15
then the condition becomes:
315 Not Equal To 315"

This is not correct. Using the information presented, the result becomes 313 Not Equal To 315.

And where can we learn about these mysterious "var1", "var2", etc.? I have been looking all over for an explanation of these. For example, why, in the original example above, do they use [var3] and [var1]? Could they have used [var9] and [var5]? Or any other of the "var" variables available?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
6 years 9 months ago #302708 by krileon

Was assuming when using multiple conditions (more than 1 row of conditions) in auto action there's an OR operator between each row of conditions.
Hence meaning: execute auto action when at least one of conditions provided is true. Am I right?

No, there are no OR conditions unless you do as explained above or use a REGEX condition operator then use the OR separator in your REGEXP. Conditions in CB Auto Actions are always AND.

And where can we learn about these mysterious "var1", "var2", etc.? I have been looking all over for an explanation of these. For example, why, in the original example above, do they use [var3] and [var1]? Could they have used [var9] and [var5]? Or any other of the "var" variables available?

The variables available is entirely dependent on the trigger used. They're the variables the trigger passes. CB Auto Actions has no clue what those are, but it maps them to var1-15 to allow access to them. You can review the below trigger list for an idea of what the variables are for a given trigger.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18358-using-cb-triggers


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