Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] Grab + modify field value and fill another field with result

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 2 months ago - 11 years 1 month ago #233143 by dotcom22
I have a Date field (cb_date) and I noticed the value stored in database look like YYYY-MM-DD when instead I would need to get DD-MM-YYYY. In fact I need to send this value in correct format to a remote server for fill a simple text field in the remote database.

So I tried to setup a Query field with this code:

Code:
SELECT DATE_FORMAT( `cb_date`, '%d-%m-%Y' ) FROM `nova_comprofiler` WHERE `user_id` = '[user_id]'



and I'm able to get my desired format. However due to the particular nature of Query field (is not s true field who store something), this is useless in my case.

I wondering how I can do for solve this problem. I suppose is possible with Auto-Action (with trigger onAfterUserRegistration) to fetch the value of my Date field (cb_date), to perform the modification (re-arrange the format) and to store the new value in a text field (cb_datetext). Then instead to send in remote server the value of cb_date, I can simply send value of cb_datetext.

I looked in available Action but none permit to do that "as is" so I imagine is required to use a Code Action. If yes could you please give me an example of code ?

many thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 1 month ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 2 months ago #233150 by krileon
Use the Request action and just substitute in the query field (e.g. [cb_date] or [of cb_datetext]). Request action lets you send POST, GET, XML, and JSON HTTP requests to any URL of your choosing with substitution support.


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 1 month ago #233160 by dotcom22
In fact my question was not exactly that...but you helped me to find the right solution for my case :woohoo: :cheer:

I used simply a Field Action for set the value (using substitution) coming from the Query field inside my field cb_datetext. Then for send the value of cb_datetext I know how to do..

The power of Auto-Action is just tremendous... Is just matter to find the right action and process...Not always easy..

Many thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
The following user(s) said Thank You: krileon

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

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 1 month ago - 11 years 1 month ago #233871 by dotcom22
Unfortunately I was wrong and my problem is partially solved. In fact as I said I need to send by POST the result of [cb_datetext] but this value could be obtained only when data are stored in database. So is not possible to get this value onAfterUserRegistration and to include this in my POST.

Any clue ?

I wondering for example if a date field could be manipulated in substitution directly in my POST url but it seem not the case. I seen this [cb:date format="Y-m-d" /] but is always related to actual timestamp and not a specific date field. Something like this [cb:userdata field="cb_birthdate" dateformat="d-m-Y" /] could be the solution but this substitution do not exist...

I seen also in Auto-Action explanation this:

Dates can also be formatted using PHP date functionality (e.g. date( Y-m-d, [cb_date] )).

So I tried to modify my POST url like this:

api.site.com/http/sendmsg?email=

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 1 month ago by dotcom22.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 1 month ago #233907 by krileon

Unfortunately I was wrong and my problem is partially solved. In fact as I said I need to send by POST the result of [cb_datetext] but this value could be obtained only when data are stored in database. So is not possible to get this value onAfterUserRegistration and to include this in my POST.

The user object is up to date at the time of onAfterUserRegistration so it should work perfectly fine. You may need to use the below usage for a query field though.

[cb:userfield field="FIELD_NAME" /]

You should not be formatting the date on your end of the request. Your endpoint, the URL you're using it to, should format it as needed. It should do a simple strtotime then date format on the result. The way it's being done now just isn't the correct way for an endpoint to be doing it.

The format functions do not work outside of conditionals, which is why it's doing nothing in your usage. It's planned to allow these format functions to be used outside of conditionals in next release though by enabling a parameter in the action, which when available you'd be able to do date(d-m-Y,strtotime([cb_birthdate])).


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 1 month ago #233914 by dotcom22

The user object is up to date at the time of onAfterUserRegistration so it should work perfectly fine.


Are you sure ? As I said the value contained in [cb_datetext] come from a Query field. So the query fetch value only if data related to [cb_birthdate] are well stored. So it seem to be strange the result of [cb_datetext] can be sent with the Post action. Anyway I tested many time and also using [cb:userfield field="FIELD_NAME" /] but this don't work..

Maybe is better I wait your next release of Auto-Action... Have you an idea when it will be ready ?

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

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

Moderators: beatnantkrileon
Powered by Kunena Forum