Skip to Content Skip to Menu

Using Auto Action to auto update one field based on the value in another field

6 years 11 months ago - 6 years 10 months ago #299181 by derekkoopowitz
I have a scenario as follows:

If a user's state/province field is a certain value then I want to populate another field (district) with a value (text) (on user registration and profile update). The problem I have is that I'm dealing with 52 states (USA). I'd like to just use SQL using an update statement and have a case statement with 52 lines but I can't do that using Auto Action. I have 11 districts and the 52 states are broken up into different districts based on their location... for instance, District 10 has AZ, CA, HI, NV, and UT.

If I create an auto action for this example, I'd have to create a new auto action for every state... isn't that correct? That means I would have 52 auto actions out there. In the current auto action, the conditions are all "AND", correct? So I wouldn't be able to add all 5 states (as above) as condition lines, because as soon as the first condition fails, then the auto action fails and is not run.

Is there a better way to do this?

Thanks for any feedback!

-Derek
Last edit: 6 years 10 months ago by derekkoopowitz.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 11 months ago #299185 by krileon

If I create an auto action for this example, I'd have to create a new auto action for every state... isn't that correct? That means I would have 52 auto actions out there.

If you need this to run per state, yes, but sounds like you want per district so you'd need a lot less.

In the current auto action, the conditions are all "AND", correct?

Correct.

So I wouldn't be able to add all 5 states (as above) as condition lines, because as soon as the first condition fails, then the auto action fails and is not run.

You'd just add them as a single REGEXP condition. Example as follows.

[cb_state] Is REGEX /AZ|CA|HI|NV|UT/

Basically separate each state with a | for an OR case in REGEX. This should mean you only need an auto action per district.


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.

6 years 11 months ago #299187 by derekkoopowitz

You'd just add them as a single REGEXP condition. Example as follows.

[cb_state] Is REGEX /AZ|CA|HI|NV|UT/

Basically separate each state with a | for an OR case in REGEX. This should mean you only need an auto action per district.


Great! And what do I set the translate, format and prepare options to?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 11 months ago #299190 by krileon
You don't need translations, format functions, or content prepare so you can safely uncheck all 3 or leave as default.


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.

6 years 11 months ago #299192 by derekkoopowitz
Great! I'm going to play with it now and will let you know.
The following user(s) said Thank You: krileon

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

6 years 11 months ago - 6 years 10 months ago #299237 by derekkoopowitz

You'd just add them as a single REGEXP condition. Example as follows.

[cb_state] Is REGEX /AZ|CA|HI|NV|UT/

Basically separate each state with a | for an OR case in REGEX. This should mean you only need an auto action per district.



When I try this I get the following:

:: Action 58 :: Conditional 1 failed for 65: cb_stateprovince Is REGEX /AZ|CA|HI|NV|UT/
×

I'm guessing the field (stateprovince) which is defined as a dropdown selection should have the field length defined as 2 - right now it is unlimited.
Last edit: 6 years 10 months ago by derekkoopowitz.

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

Moderators: beatnantkrileon
Powered by Kunena Forum