Skip to Content Skip to Menu

Count field groups

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 1 week ago - 2 years 1 week ago #331103 by galanopd
Count field groups was created by galanopd
2 questions

1. Is there a way to count the number of field groups a user has created?
I need to use it in an int field

2. How can I use lastupdatedate to get the last modified date of a field rather than the profile?

Thanks
Last edit: 2 years 1 week ago by galanopd.

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
2 years 1 week ago #331108 by krileon
Replied by krileon on topic Count field groups

1. Is there a way to count the number of field groups a user has created?

Outside of the field group? No. You'd need to use PHP to process the JSON and count the array result. If this doesn't need to be stored in the database the easiest way to do this is with a Code field.

2. How can I use lastupdatedate to get the last modified date of a field rather than the profile?

We don't keep track of individual field modified dates. You'd need to implement that yourself using a date field and CB Auto Actions to update the date field based off whatever field you want to monitor changing values. You can use the below to perform any auto action on field value change.

Global
Triggers: onAfterUserUpdate
User: Automatic
Access: Everybody
Conditions
Field: Custom > Value
Custom Value: [var1_FIELD_NAME]
Operator: Not Equal To
Value: [var3_FIELD_NAME]


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 or Create an account to join the conversation.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 1 week ago - 2 years 1 week ago #331140 by galanopd
Replied by galanopd on topic Count field groups

We don't keep track of individual field modified dates. You'd need to implement that yourself using a date field and CB Auto Actions to update the date field based off whatever field you want to monitor changing values. You can use the below to perform any auto action on field value change.

AA->Conditions checks var1 and var3 of the FIELD_NAME based " onAfterUserUpdate" which I suppose it means that the field has been updated in case they are not equal . Further I need the DATE_FIELD in AA->Action to get Date('now'). I have enabled "Format Functions"  and used Value-> [cb:parse function="date" date-format="d/m/Y"]now[/cb:parse]. I have also checked that the DATE_FIELD Parameters->Display->EditDisplay->Custom and Custom date edit format->d/m/Y and Ajax Updateon FIELD_NAME, but the DATE_FIELD does not update with current date.
 
Last edit: 2 years 1 week ago by galanopd.

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
2 years 1 week ago #331146 by krileon
Replied by krileon on topic Count field groups
When formatting the date you need to use SQL format as that's how it's stored. Try the following.

[cb:parse function="date" date-format="Y-m-d" time="false"]now[/cb:parse]

FIELD_NAME should be replaced with whatever the name of the field that you're wanting to check if has been updated. So for example I have a text field called cb_text then I'd replace FIELD_NAME with cb_text.


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.

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 1 week ago - 2 years 1 week ago #331153 by galanopd
Replied by galanopd on topic Count field groups
Maybe I haven't described it well.
Yes, I have replaced FIELD_NAME with the name of the field.
Still I have used [cb:parse function="date" date-format="Y-m-d" time="false"]now[/cb:parse], no luck...

I have turned on debug for the AA and it reports
Code:
Error:: Action 164 :: Condition 1-1 failed for user 18 with "0" Not Equal To "0"
Which means that although I change the value of the field (it is an INT field) it is not understood by the AA

EDIT: I have also noticed the following, when I set it to onBeforeUserProfileEditDisplay the "now' is parsed to the DATE_FIELD and it shows the today's date. Still when I click on update to exit the edit profile, the Debug shows the error message. So it looks like there is something wrong with onAfterUserUpdate?

EDIT2: Even this [cb:parse function="clean" method="int"][var1_FIELD_NAME][/cb:parse] doesn't seem to work

EDIT3: If the FIELD_NAME is a text field it works fine. So it has to do with the syntax for the int field? Is what I have in EDIT2 wrong?

EDIT4: The problem is solved after I tried almost everything possible! The last resort was to create a new INT field and then it worked. There was something wrong with the old one. I thnk this happens quite often, especially when changing a field from one type to another causing it not to operate properly, although in my case I do not remember changing it (but you never know). Thanks anyway
Last edit: 2 years 1 week ago by galanopd.

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

  • galanopd
  • galanopd
  • OFFLINE
  • Posts: 374
  • Thanks: 49
  • Karma: 8
2 years 1 week ago - 2 years 1 week ago #331155 by galanopd
Replied by galanopd on topic Count field groups
After all none of the above mentioned EDITs is valid.

Here is the real cause.

1. It works when both FIELD_NAME and DATE_FIELD are out of a field group. When either one or both are inside the field group the AA fails to work for the INT field.
2. When you add the INT field inside the field group and then check on profile edit, its previous value changes and it turns to 0 BUT AAs debug shows its old value. Now, even if you change INT field value while inside the field group and click on update, although the new value is saved, AAs debug still shows the old value!

So in other words, AA does not understand any change in the INT field when inside a field group.

 
Last edit: 2 years 1 week ago by galanopd.

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

Moderators: beatnantkrileon
Powered by Kunena Forum