how to substitute for a field that is part of a field group

1 month 2 weeks ago #337641 by markfajgenbaum
Hi Support, 

how can i use CB substitution where a field is part of a field group?  when i call the field as a substitution, e.g. [cb:userdata field="FIELD_NAME" /] it seems to show up empty if that field is part of a field group, or if it is a multi-select field.  

thanks for any advice, 
Mark

Please Log in to join the conversation.

1 month 2 weeks ago #337642 by krileon
It's a bit complicated, but it is doable. The names of fields inside of their field groups will still be the same as the original fields, but you have to take into account the row number. Example as follows.

Field Group: cb_fldgrp
Field: cb_city
Row: 1
Substitution: [cb_fldgrp_0_cb_city]

The problem is row indexes are not always sequential. So this may not be very accurate. It's very difficult pulling information out of a field group and I really don't recommend trying to do so as it goes against the point of using them. If you need a dedicated value for external referencing consistently you really shouldn't use a field group.


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.

1 month 2 weeks ago #337646 by markfajgenbaum
Thanks for clarifying Kyle.  I think calling the row number as you've shown will be problematic in my use case e.g. if a user deletes a group entry in preference for another more recent group entry then that old row number disappears, so calling a fixed row number will return an empty value.  The use cases i would have for calling a field associated with a group field (and prob similar for other users) would be for: 

- retrieving the *most recent* entry for the field_group 
- displaying all the entries for that field (e.g. user x works in the following towns: x, y, z) 

I guess I would need to use a separate code field to do this using sql or php? 

Please Log in to join the conversation.

1 month 2 weeks ago #337655 by krileon
If you only need the last entry or first entry there are pseudo indexes for those. Example as follows.

[cb_fldgrp_first_cb_city]
[cb_fldgrp_last_cb_city]

Beyond that it is not really reliably possible to do this with substitutions. The more ideal approach would be to use a CB Code Field and write the necessary PHP to process the field groups JSON into whatever format you need. I doubt substitutions alone will ever be able to satisfy your requirements as there just isn't a reliable enough way to retrieve that data using unknown indexes.


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

Facebook Twitter LinkedIn