[SOLVED] Auto Action Query questions and 'reload' #me

3 weeks 4 days ago - 2 weeks 2 days ago #308697 by rgarderet
Dear Kyle,
I have a couple of related challenges with CB auto actions.

I have several Query auto actions that are changing fields in the CB user database. They update fields related both to the logged in user (#me) and the profile I am viewing [user_id]. These are now working fine.

What I need is to be able to send an email with some of those updated field values, after they are changed by those Queries.

1. Is there a trigger that I could use to fire when a Query updates a field value? I’ve tried both AfterUserUpate and AfterUpdateUser and they don’t seem to be trigger when these values are changed by the Query actions. This would be ideal, then I could just have a single email send updated values whenever a user is modified using these Query Auto Action. (I guess I'm looking for something equivalent to the "Save Directly" that alllows this for "field" type actions.)

2. Alternatively, I’ve tried using an email AutoAction, triggered after the Query one. It fires successfully, but rather than send the newly updated fields from the logged in user (#me), it sends the old ones, prior to the changes made in the Query action. I have the “reload user” on “yes” for both Actions, but I guess what I really need is a reload of the logged in person’s information, not the user profile being viewed. Is there some way to do that?

I’d appreciate any guidance.
Thanks,
Remy.
3 weeks 2 days ago #308707 by krileon
If possible I suggest using the Field action instead of a query action which if configured to do so will fire normal profile update triggers. Aside from that you'll need to use the auto action chaining feature in CB Auto Actions. This is done by acting on the autoactions_onAction trigger which is fired when an auto action is executed, but you need to be careful with this one as it's possible to get stuck in a loop if not setup correctly. You'll need to at the very least use the below condition.

[var2_id] Equal To AUTO_ACTION_ID

Replace AUTO_ACTION_ID with the ID of the auto action you want to act after. The following variables are available to this trigger.

$_PLUGINS->trigger( 'autoactions_onAction', array( &$content, &$autoaction, &$user, &$variables, &$substitutions ) );

So for example var2 is the auto action being executed.

Also since you're using a Query action to update field values the field values won't be updated in the user object. So you need to be sure to enable Reload User under Parameters of the chained auto action so it can update the user object with the latest stored values. The Reload User feature only applies to the User parameter; so the user being considered as the executor for the action.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
3 weeks 2 days ago #308711 by rgarderet
Dear Kyle,
Thanks for your reply. I had previously tried to set up my actions as Field updating ones, but couldn't figure out how to make the calculations do what I need. Attached are the ones that are working using the Query, and you'ss see they use CONCAT, LENGTH, and REPLACE functions.

Is there a way to do this in a Field action? If I chose Set (Field=Value), can I put these kinds of formulas in there?

e.g.
Field: cb_requested_by_currently
Value: CONCAT(cb_requested_by_currently, "[cb:userdata field="Id" user="#me" /],")
Save Directly: No
User: [user_id]

Also, I am able to string actions together, but:
1. Can one action launch two separate actions? (i.e. have the two actions refer to the same triggering one)
2. Can an action be triggered by a re-direct action?

Thanks,
Remy.
Attachments:
3 weeks 2 days ago #308712 by rgarderet
Sorry - one clarification. I was able to do the "CONCAT" function by using the the "Suffx" option in the Field Actoin, but it was actually my inability to figure out how to do a strong REPLACE equivelant that led me to use Query Actions in the frst place, so if you have any tips on how to do those, that would be the key.
Thanks,
Remy.
3 weeks 1 day ago #308731 by krileon

1. Can one action launch two separate actions? (i.e. have the two actions refer to the same triggering one)

Using the trigger and condition in my previous reply you can chain as many as you want together.

2. Can an action be triggered by a re-direct action?

If your redirect is to an auto action URL sure, but if you mean to chain after a redirect action then no as the redirect happens before the trigger fires so you won't be able to chain after a redirect and should do the redirect last.

Sorry - one clarification. I was able to do the "CONCAT" function by using the the "Suffx" option in the Field Actoin, but it was actually my inability to figure out how to do a strong REPLACE equivelant that led me to use Query Actions in the frst place, so if you have any tips on how to do those, that would be the key.

Review the available format functions under the Parameters tab as you've access to a lot of PHP functions that you can run on your string. This includes PHP replace and more. Be sure to enable format functions under the parameters tab as well if you intend to use them.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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: rgarderet
2 weeks 5 days ago #308801 by rgarderet
Thanks for your help. I was able to do it using Field Actions. The key was that I hadn't realized that you could use the "Format" functions TOGETHER with the substitutions as the "Value" being set by the action.
The following user(s) said Thank You: krileon
Moderators: beatnantkrileon
Time to create page: 0.495 seconds
Facebook Twitter Google LinkedIn