Skip to Content Skip to Menu

Moving from SQL script to Internal Users trigger

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
9 years 9 months ago - 9 years 9 months ago #256592 by fribse2011
I currently have a SQL script:
Code:
UPDATE `xxx_comprofiler` SET `cb_rykker` = 1 WHERE ( MONTH(NOW()) >= 11 AND `cb_type` NOT IN ('Ikke Medlem','') AND `cb_betalt` NOT LIKE CONCAT('%',YEAR(NOW())+1,'%' ) AND `cb_udmeldt` <> 1 )

I would like to change this to do it in autoactions.
What it does is, if it's november or december, and the year+1 does not appear in 'cb_betalt' the user get's a flag set (cb_rykker).

I was thinking along the lines:
Code:
Field auto-action Access Everybody Trigger Internal Users Conditions RegEx is [Membershiptype list] cb_betalt does not contain year+1 month >= 11 Field cb_rykker = 1

Is there a CB substition that gives me current month and year?

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Last edit: 9 years 9 months ago by fribse2011.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48480
  • Thanks: 8283
  • Karma: 1443
9 years 9 months ago #256618 by krileon
You can get the current month using the below substitution.

[cb:date format="m" /]

However your year + 1 condition will be an issue. With the current format function behavior it's not very easy to do as stacking functions doesn't work right now. For this I suggest a CB Query Field then condition against the query field, which would query for cb_betalt and add a year.

Is there a reason you're moving away from a query? The field action does a direct database query then sets the value in the user object. So using a direct query is fine unless you're needing the profile update trigger to fire, which the field action doesn't fire either.


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.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
9 years 9 months ago #256637 by fribse2011
Replied by fribse2011 on topic Moving from SQL script to Internal Users trigger
Currently it's running from the CRON as a SQL script. So I get the flag set, but I can't do anything else.
It would be nice to be able to do other stuff as well, like send an email to the user, that the flag is set.

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48480
  • Thanks: 8283
  • Karma: 1443
9 years 9 months ago #256738 by krileon
There's an email action which could be used to send an email to the user. You can use whatever actions you like on the Internal Users trigger and they'll fire when that URL is accessed on every user row; this can be a heavy process though.


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