How to extract data from one field, parse it, and store it in 4 other fields

4 weeks 13 hours ago #320596 by pgay@patrickgay.com
I have a checkbox field with 4 possible options: 1, 2, 3, 4. (fieldname cb_volunteer_type)
A user can select multiple options.
I need a way to take that information and populate four individual fields so that I can pass that data to another application. (cb_volunteer_type_1,cb_volunteer_type_2, cb_volunteer_type_3, cb_volunteer_type_4)
In the database, it's stored as 1|*|2|*|3|*|4. I can write MID sql statements to extract the data, I can't however, figure out how to make CB update the individual fields, for example:
A user selects volunteer type 1 and 3. The cb_volunteer_type field is now set to 1|*|3.
When the CB Auto Action is done, this would be the final result:
cb_volunteer_type_1 = 1
cb_volunteer_type_2 = 3
cb_volunteer_type_3 = null
cb_volunteer_type_4 = null

Anyone have any ideas about how to do this in CB Auto Actions? Of course, if there is a better way to do this, I'm up for that as well. The only requirement is that I be able to store each item in its own database field.
Thanks

Please Log in to join the conversation.

3 weeks 6 days ago #320609 by krileon
Why do they need to be stored if they're being passed to an external application? If you're storing them then just make them individual fields otherwise you'd have storage for 5 fields instead of 4 and just duplicating data, which both situations are bad practice.

You should implement the processing into 4 individual fields when you pass it on to your external application. How are you passing the data to an external application would determine how doable this is though. If for example using CB Auto Actions it should be completely doable to split it using format functions.


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.

3 weeks 6 days ago #320615 by pgay@patrickgay.com
Hi and thanks for the feedback. The system I am using is Joomdle which is an intermediary connector to Moodle. The Joomdle application interfaces with CB, but all I can do is have it get the data from a database field and pass it to Moodle. That means I'll have to store them individually. I can consider using 4 individual fields, I'd just need to know how to line them up like a checkbox style field with labels and check boxes to select. Hopefully this helps explain it further. Thanks

Please Log in to join the conversation.

3 weeks 5 days ago #320627 by krileon
In that case 4 individual fields makes sense or contacting the developers of Joomdle to see if they'd consider implementing support for multi-select and multi-checkbox fieldtypes, which are always joined by |*| in storage, to better allow for passing data. As for lining 4 individual fields up to look like you a multi-checkbox you won't really be able to do that since single checkbox and multi-checkbox just completely display differently.


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.

3 weeks 5 days ago #320631 by pgay@patrickgay.com
So, knowing all this, how can I use CB Auto Action to take the data from 1 field, parse it and store it into 4 other fields? It looks like Auto Action might do it, but I can't figure out how and there isn't any documentation on AutoAction that I can find to tell me how.

Please Log in to join the conversation.

3 weeks 5 days ago #320636 by krileon
It can do that using a Field action, but again I highly recommend you do not do this. You're storing a field twice. This is a situation of either change the field setup or improve Joomdle (this would be the best approach as appears Joomdle just flat out doesn't support multi-select fieldtypes). Regardless if you insist on doing this the below can be used to change a fields value.

Global
Triggers: onAfterUserRegistration, onAfterNewUser, onAfterUserUpdate, onAfterUpdateUser
Type: Field
User: Automatic
Access: Everybody
Action
Field: CHECKBOX_FIELD
Operator: Set
Value: [cb:if FIELD_NAME=~"FIELD_VALUE"]1[cb:else]0[/cb:else][/cb:if]

Select your checkbox field for CHECKBOX_FIELD. Replace FIELD_NAME with the name of your multi-checkbox. Replace FIELD_VALUE with the value in that multi-checkbox that represents CHECKBOX_FIELD. It should toggle its checked state based off the multi-checkbox. Use the "Add Rows" button and to this for each value of the multi-checkbox field that you want to pass to individual checkbox fields so this can all be done in a single auto action.


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.415 seconds

Facebook Twitter LinkedIn