Skip to Content Skip to Menu

check for duplicates

  • azjr
  • azjr
  • OFFLINE
  • Posts: 99
  • Thanks: 10
  • Karma: 2
9 years 2 months ago - 9 years 2 months ago #269919 by azjr
check for duplicates was created by azjr
Hi - could you please advise what and/or how to use the available CB tools/plugins/whatever to ensure that some fields are not entered the same value?
Example: fields for primary (required) + alternative emails; or phone numbers that must be unique: ideally a way to query and return error message if the value already exist.
Thanks!
Last edit: 9 years 2 months ago by krileon.

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

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
9 years 2 months ago #269933 by nant
Replied by nant on topic check for duplicates

azjr wrote: Hi - could you please advise what and/or how to use the available CB tools/plugins/whatever to ensure that some fields are not entered the same value?
Example: fields for primary (required) + alternative emails; or phone numbers that must be unique: ideally a way to query and return error message if the value already exist.
Thanks!


These 2 videos might help you:

www.youtube.com/playlist?list=PLp0puRITgC7MM9iP9FooKB1qk8f5MLWVp
The following user(s) said Thank You: azjr

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
9 years 2 months ago #269937 by krileon
Replied by krileon on topic check for duplicates
CB Query Field and its Query Validation feature can be used to query the _comprofiler table to ensure another user hasn't already entered the value supplied by the user. See the below videos to get started.

www.youtube.com/playlist?list=PLp0puRITgC7MM9iP9FooKB1qk8f5MLWVp


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

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

  • azjr
  • azjr
  • OFFLINE
  • Posts: 99
  • Thanks: 10
  • Karma: 2
9 years 2 months ago - 9 years 2 months ago #269978 by azjr
Replied by azjr on topic check for duplicates
OK guys, I need to ask probably embarrassing question, but I can't get the query right - the goal is to look for the duplicate values within the same ID - so that if user have entered value into cb_phone1, s/he canno't enter the same value in the cb_phone2.
So the validation is "horizontal" rather than vertical - any thoughts?
thanks!

~~~~~~
(few hours later...) - this is interesting:
I can validate email fields with the query:
Code:
SELECT * FROM `#__users`, `#__comprofiler` WHERE `email` = '[value]' OR `cb_pg1email2` = '[value]' OR `cb_pg2email2` = '[value]'
and I'm getting the correct results... BUT when I try to do the same with phone fields, nothing... all is ignored.
The difference between the email and phone fields is that I'm using regex on phone:
Code:
/^[\(](?<area>\d{3})[\)][ ](?<group1>\d{3})[-](?<group2>\d{4})\W*?$/
to force the entry: (999) 999-9999
Do you think this can have something to do?
Last edit: 9 years 2 months ago by azjr. Reason: new findings - update

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
9 years 2 months ago #270007 by krileon
Replied by krileon on topic check for duplicates
The query validation is per field. So if you want to validate your phone field you need to edit your phone field in CB > Field Management then add query validation specifically for it. Example as follows.

Query Validation: Enabled
Query:
Code:
SELECT `id` FROM `#__comprofiler` WHERE `cb_phone` = '[value]'
Validate On: Empty Results
Ajax Validation: Enabled

Your email one would be as follows.

Query Validation: Enabled
Query:
Code:
SELECT u.`id` FROM `#__users` AS u LEFT JOIN `#__comprofiler` AS cb cb.`id` = u.`id` WHERE ( u.`email` = '[value]' OR cb.`cb_pg1email2` = '[value]' OR cb.`cb_pg2email2` = '[value]' )
Validate On: Empty Results
Ajax Validation: Enabled


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.

  • azjr
  • azjr
  • OFFLINE
  • Posts: 99
  • Thanks: 10
  • Karma: 2
9 years 2 months ago #270023 by azjr
Replied by azjr on topic check for duplicates
hmm... I can't validate with that email query:
scenario: example:
after user provides the email (the required one), there are 3 more email fields (optional): email2,email3,email4 - so if user attempts to enter the same email address into any of those fields, user should get the error validation.
Now, by no means my sql is perfect, but it does work - I have entered the following variation values under each field's query validation (the "SELECT * FROM `#__users`, `#__comprofiler` " is the same in all queries, only the WHERE portion changes:)

email:
WHERE email=value OR email2=value OR email3=value or email4=value

email2:
WHERE email=value OR email3=value OR email4=value

email3:
WHERE email=value OR email2=value OR email4=value

email4:
WHERE email=value OR email2=value OR email3=value

Please advise - thanks!

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

Moderators: beatnantkrileon
Powered by Kunena Forum