[SOLVED] Pass Code field value to a searchable field

1 year 7 months ago - 1 year 7 months ago #330538 by galanopd
I have a PHP Code field with various if statements that create a value based on different users.
For instance User1= 0.64, User2=10.32, etc
I need to pass this value to a searchable field (ajax updated), in order to use it in a list for indexing for the displayed users.

Any idea on which field type to use and how to implement this?

Please Log in to join the conversation.

1 year 7 months ago #330545 by krileon
Replied by krileon on topic Pass PHP Code value to a searchable field
Don't understand what you're trying to do, sorry. You need the code fields value in another field for searching? What is the field type of the field you're trying to search?


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 year 7 months ago - 1 year 7 months ago #330554 by galanopd
Replied by galanopd on topic Pass PHP Code value to a searchable field
Sorry, maybe I haven't described it well.

So, the Code field has a PHP code that produces a value, for instance, User1 gets 0.64, User2 gets 10.32, etc
Since this type of field (Code field) is not Searchable, I need somehow to pass its value (the value produced for each different user) to a Searchable field in order to use this Searchable field in a list and sort the list by this value.
The Searchable field can be anything you suggest

 

Please Log in to join the conversation.

1 year 7 months ago #330556 by krileon
Replied by krileon on topic Pass PHP Code value to a searchable field
You can usually accomplish that by using CB Auto Actions to update a text field then you can search the text field. Given this is strictly a decimal number I recommend using a Decimal Number field type though. The below auto action can be used to keep the field in sync.

Global
Triggers: onAfterUserRegistration, onAfterNewUser, onAfterUpdateUser, onAfterUserUpdate
Type: Field
User: Automatic
Access: Everybody
Action
Field: DECIMAL_NUMBER_FIELD_HERE
Operator: Set
Value: [FIELD_NAME]

Change FIELD_NAME to whatever the name is for your code field. Now when their profile is updated or when a user registers it'll set the code fields value into your decimal number field.


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 year 7 months ago - 1 year 7 months ago #330568 by galanopd
Replied by galanopd on topic Pass PHP Code value to a searchable field
Ok I understand the logic but it returns 0 because the PHP in the Code field returns many things.
I need to get the value of only one variable ($index).  So,
Action
Field: DECIMAL_NUMBER_FIELD_HERE
Operator: Set
Value: [FIELD_NAME] ->  should be something like [get_$index] ???

Or maybe it should be in the "Output" tab with a parse function?
Totally lost here...

Please Log in to join the conversation.

1 year 7 months ago #330586 by krileon
Replied by krileon on topic Pass PHP Code value to a searchable field
If you need it to store $index then have your code field return $index. Code fields are just PHP. They have no storage so make as many of them as you need to. So for example create a second one that just returns $index.


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.
The following user(s) said Thank You: galanopd

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.220 seconds

Facebook Twitter LinkedIn