Skip to Content Skip to Menu

[SOLVED] Field updated when another field edited

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 212
  • Thanks: 31
  • Karma: 5
6 years 11 months ago - 6 years 11 months ago #294610 by bizguy
Following up on my previous post:
forum/255-developer-members-support/236772-solved-code-field-update-when-another-field-is-edited

So either my logic is wrong, or I have configured something incorrectly but here is what I am trying to do:
  • I have a 3 separate query select fields where a member selects their 1st, 2nd & 3rd city choices (working correctly)
  • I have 3 separate datetime fields to record the date and time of each city choice/change above
  • I switched from using code fields (the previous post noted above) to 3 query fields which each set to update each date field when that city is changed

I update each field separately using each city change as its ajax trigger, however when I change any one, all 3 are updated to the new time.

Suggestions?
Last edit: 6 years 11 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 212
  • Thanks: 31
  • Karma: 5
6 years 11 months ago #294618 by bizguy
Replied by bizguy on topic Field updated when another field edited
So here is an update:
The datefield is being updated on each page view? This is not just the date view, but the date in the field in the table. Could this be the result of using a query, although ajax updating the field is supposed to only happen at registration and profile edit I had read.

Here is the code and settings I am using at each stage:
  • The select query for the city:
    cb_city_one
    SELECT `province`, `city_name`, `city_id` FROM `#__townlocations_canada` ORDER BY province, city_name
    integrations: none
  • The datetime field:
    cb_choice_one
    format: Default settings
    integrations: none
  • The query date field:
    cb_pick_one
    UPDATE `#__comprofiler` SET `cb_choice_one` = NOW() WHERE `#__comprofiler`.`user_id` = [user_id]
    integrations: Update On: cb_city_one

Suggestions/corrections are appreciated.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68609
  • Thanks: 9109
  • Karma: 1434
6 years 11 months ago #294621 by krileon
Replied by krileon on topic Field updated when another field edited
Doing an update query means it will do that update every single time the field is output. You'll need to use a Query or Field action in CB Auto Actions do the update once or based off whatever criteria you need. Assuming cb_choice_one is a datetime field the below would work.

Global
Triggers: onAfterUserUpdate
Type: Field
User: Automatic
Access: Everybody
Conditions
1: [cb_choice_one] Equal To 0000-00-00 00:00:00
Action
Field: cb_choice_one
Operator: Set
Value: [cb:date format="Y-m-d H:i:s" /]


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.

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 212
  • Thanks: 31
  • Karma: 5
6 years 11 months ago #294624 by bizguy
Replied by bizguy on topic Field updated when another field edited
Thanks Kyle.
If I want to update the datetime field every time the city selection is changed, is there a different condition I can use?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68609
  • Thanks: 9109
  • Karma: 1434
6 years 11 months ago #294634 by krileon
Replied by krileon on topic Field updated when another field edited
Yup, you can check to see if the city field change its value using the below condition.

[var1_cb_city_one] Not Equal To [var3_cb_city_one]

var1 is the new user object with their most recent changes. var3 is the user object before the profile update. Using those two variables you can compare fields to see if they were changed.


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: bizguy

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

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 212
  • Thanks: 31
  • Karma: 5
6 years 11 months ago #294638 by bizguy
Replied by bizguy on topic Field updated when another field edited
Thanks again Kyle.
You have really built an incredible extension.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn