Add a date to a CB Field

14 years 7 months ago #110187 by toddfletcher
Add a date to a CB Field was created by toddfletcher
I need to add the current date to a custom user field at the time a subscription is made. I don't see a way to do that in the sub Integration tabs... so I thought maybe I could add it using a SQL query. Here's way I can so far. It doesn't see to have an effect.

UPDATE '#_comprofiler' SET 'cb_customfield' = CONVERT (date, GETDATE()) WHERE `user_id` = [user_id]

Thoughts?

Todd

Please Log in to join the conversation.

14 years 7 months ago #110193 by krileon
Replied by krileon on topic Re:Add a date to a CB Field
UPDATE `#_comprofiler` SET `cb_customfield` = NOW() WHERE `user_id` = [user_id]

OR

UPDATE `#_comprofiler` SET `cb_customfield` = CURDATE() WHERE `user_id` = [user_id]

OR your original but fixed

UPDATE `#_comprofiler` SET `cb_customfield` = CONVERT (date, GETDATE()) WHERE `user_id` = [user_id]

You single quoted tables and columns. Use ` instead of '. Only use ' and " for values.


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.

14 years 7 months ago #110233 by toddfletcher
Replied by toddfletcher on topic Re:Add a date to a CB Field
The fields doesn't change when I add the subscriptions to a user. It remains blank.

I added a custom field called cb_workshop001. It is a date type. The field-specific parameters are default. I haven't touched the CBSubs Fields Tab Protect... area.

The SQL string is copied and pasted in to the SQL Action 1 on ACTIVATION area.

Yet when I add the subscription to the a user, the cb_workshop001 field remains empty.

Help.

Thanks.
Todd

Please Log in to join the conversation.

14 years 7 months ago #110240 by krileon
Replied by krileon on topic Re:Add a date to a CB Field
It's probably not in the right format. Also just noticed an error with the table name.

Change:
#_comprofiler
To:
#__comprofiler

Example:
UPDATE `#__comprofiler` SET `cb_customfield` = DATE_FORMAT( CURDATE(), '%Y-%m-%d' ) WHERE `user_id` = [user_id]


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.

14 years 7 months ago #110257 by toddfletcher
Replied by toddfletcher on topic Re:Add a date to a CB Field
Thanks for the reply. I still don't have the custom field updated.

The difficult thing is that there is not error message or log to see it the SQL is invalid and why. Do you know of a way to test it? Maybe using phpMyAdmin?

thanks
Todd

Please Log in to join the conversation.

14 years 7 months ago #110263 by toddfletcher
Replied by toddfletcher on topic Re:Add a date to a CB Field
I just tried phpMyAdmin and the following worked:

UPDATE `jos_comprofiler` SET `cb_workshop001` = DATE_FORMAT( CURDATE(), '%Y-%m-%d' ) WHERE `user_id` = 66

But then I put the following in cbSubs... and the field is still blank:

UPDATE `jos_comprofiler` SET `cb_workshop001` = DATE_FORMAT( CURDATE(), '%Y-%m-%d' ) WHERE `user_id` = [user_id]

Thoughts?

Todd

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.500 seconds