Skip to Content Skip to Menu

How to store vaule from a code field?

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 327
  • Thanks: 42
  • Karma: 9
7 years 7 months ago #286623 by cpaschen
How to store vaule from a code field? was created by cpaschen
I have a rather complex php code entry in a code field.
It is doing it's job and the proper results are being calculated and displayed;
However, now I need to store the returned value into the database field.

I selected onAfterUserUpdate for the trigger (although I'm not 100% sure that is the proper one ... not sure how that is different from onAfter Update user or one of the profile triggers).

Then for the action, I set:

* Field - the field that I'm trying to set (field1)
* Operator - Set (Field = Value)
* Value - the same field name ([field1]) using substitutions

However, the value is still not being set.

What is the proper way to do this?
What is the proper value field substitution to use the calculated value?

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

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 327
  • Thanks: 42
  • Karma: 9
7 years 7 months ago #286626 by cpaschen
Replied by cpaschen on topic How to store vaule from a code field?
Also - the code field would only be updated and saved on initial registration. After that it is not going to change.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68607
  • Thanks: 9108
  • Karma: 1434
7 years 7 months ago #286645 by krileon
Replied by krileon on topic How to store vaule from a code field?
The [FIELD_NAME] usage returns the profile value of a field. Ensure your code field is set to display on profile then retry. You can also try using [cb:userdata field="FIELD_NAME" /] usage.


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.

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 327
  • Thanks: 42
  • Karma: 9
7 years 7 months ago #286674 by cpaschen
Replied by cpaschen on topic How to store vaule from a code field?
OK ... I finally tracked down the problem, within the actual CODE parameters of the code field.

However, I've run into another problem.

Part of my code does a validation check. But it is trying to validate field value before any data is entered in the form.

Can an AutoAction be used to validate entries and alert the user BEFORE the data is actually saved to the db?
If so, what trigger would I use for that?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68607
  • Thanks: 9108
  • Karma: 1434
7 years 7 months ago #286693 by krileon
Replied by krileon on topic How to store vaule from a code field?
Just turn off ajax code validation or implement in your validation code to handle no value being supplied. Can't suggest anything further without better understanding of what you're trying to do with the code field.

Yes, CB Auto Actions can reject a profile update or registration by adding an error to the user object (reference variable would need to be configured) or triggering a plugin error but you're better off just adjusting your code field usage. You'd use the same update and registration triggers as other usages but use Before instead of After.


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

Facebook Twitter LinkedIn