[SOLVED] CBSubs: CB Fields integration not working on deactivation

8 years 2 months ago #278657 by sarah963
The quick fix is only working to remove the values and not actually assigning 0 as a field value for deactivation, meaning it returns null.

Also, if you have two fields, the quick fix only works on one of them!

I think I might use sql actions for now just like what lousyfool suggested..

Please Log in to join the conversation.

8 years 2 months ago #278663 by krileon
The quick fix just allows the CB Auto Actions to actually load. The below usage I've tested working perfectly fine to toggle a checkbox field.

Plan Active
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A
Action
Field: cb_checkboxsingle
Operator: Set
Value: 1
Translate Value: No

Plan Expired
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Not Equal To A
Action
Field: cb_checkboxsingle
Operator: Set
Value: 0
Translate Value: No

If you've anything else altering the user object on the same trigger then you may have a user loading issue. The user object is not modified by reference, because CB Auto Action can't know what trigger variables are references. Those have to be manually set under Parameters. You can also set the next actions in the chain to reload the user object under the Parameters tab to help avoid this issue.


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.

8 years 1 month ago - 8 years 1 month ago #278860 by sarah963
ok here is what I have..

I have 11 plans, and on each one of them I have two CB fields: plan_type and plan_status
Plan_type is set to 1,2,3,4,5,6,7,8,9,10, or 11 depending on which plan
Plan_status is set to either 0,1 --> that is active or not active.
The two fields are radio-buttons.
Inside each plan I set the two CB fields ..
1 and deactivate to 0, 1 and deactivate to 0
2 and deactivate to 0, 1 and deactivate to 0
---- etc.

on the auto action; I have the following:

Plan Active
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] IS REGEX /1|2|3|4|5|6|7|8|9|10|11/
2: [var2] Equal To A

Note: I did not use the "action" part here because the field are set correctly to their respective values when a user subscribe.

Plan Expired
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] IS REGEX /1|2|3|4|5|6|7|8|9|10|11/
2: [var2] Not Equal To A
Action
Field: cb_plan_status
Operator: Set
Value: 0
Translate Value: No

Field: cb_plan_type
Operator: Set
Value: 0
Translate Value: No

So, with these settings, the two fields are correctly set to their respective values when activate, but when deactivate they return null. that is I don't see the Not Active radio button selected. on both fields.. they become all not-selected.

Maybe, because these two fields are radio-buttons?! It may work with checkboxes? I don't know !!
For now, i will settle for this till you find a fix or I find a workaround

Thanks :)

Please Log in to join the conversation.

8 years 1 month ago - 8 years 1 month ago #278864 by krileon
Should set them to 0 fine, but yes it could be due to the type of field you're using. My test was with a single checkbox field, which correctly set 1 and 0 directly in the database.

I don't recommend using 0 for select fieldtypes, but maybe 1 and 2 or -1 and 1. During the IF checks it could cause issues with 0 and '' being treated the same.

To confirm what value is actually being set be sure to check your database table _comprofiler and review the users row before and after expire/cancel.


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.

8 years 1 month ago #278906 by sarah963
oh I am sorry it's not NULL..
Nothing is recorded in the database!
When the plan is deactivated the old value just disappeared. It seems like the auto action just erase the value of the field ,,,

I tired -1 instead of 0 in all places, inside the plans, the two fields themselves and the auto-action, and I got the same results.

Please Log in to join the conversation.

8 years 1 month ago #278948 by krileon
You may have something else controlling the field value then. Ensure CBSubs Fields or a direct query with CBSubs SQL Actions isn't also controlling the fields value. CB Auto Actions will always set the field value to exactly as you specified, but something also altering the fields value after CB Auto Actions does will overwrite its change.


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.

Moderators: beatnantkrileon
Time to create page: 0.479 seconds

Facebook Twitter LinkedIn