CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Complex AJAX Queries
Pages: [1]

Author Topic: Complex AJAX Queries  (Read 479 times)

JohnFF

  • I post frequently
  • ***
  • Posts: 235
  • Karma: 6
  • CiviCRM version: 4.4.13
  • CMS version: Drupal 7.28
  • MySQL version: 5.5.31-1
  • PHP version: 5.3.27
Complex AJAX Queries
October 30, 2013, 08:31:22 am
Hi gang,

So the UK Phone Number Validator is growing rapidly, and now contains filters!  8)

But it turns out that people don't want to sit and clean up thousands of phone numbers! :P

Consequently, I have grand plans for a newer version, which in addition to facilitating this kind of semi-automated data cleaning, will come with several buttons for automated data cleaning.

1) Removing duplicate phone records that belong to the same contact.  ;D
2) Reassign all valid mobile numbers to be landline numbers if they look like a mobile number.  :D
3) The same as 2, but the other way round.  ;)
4) (possibly even) remove a phone number if it has been assigned to two contacts.   ???

The problem is that our AJAX API doesn't seem to allow for these kind of complex queries.

I particularly want to use AJAX here, instead of say a URL that includes this request, as it'd be useful to display the results to the users afterwards: 1899 records adjusted.

What is the best way to do this inside a CiviCRM extension?

Thanks,
If you like empowering charities in a free and open way, then you're going to love Civi.

Email Amender: https://civicrm.org/extensions/email-amender
UK Phone Validator: https://civicrm.org/extensions/uk-phone-number-validator
http://civifirst.com
https://twitter.com/civifirst

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Complex AJAX Queries
October 30, 2013, 10:31:14 am
Not sure what's missing in the ajax.

whatever the api does the ajax will let you do. so what's missing is your extension having a new api.phone.domagiccleaning

that returns how many phones have been fixed

and you override the default CRM.api success:function(data) {//and display whatever you want}
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Complex AJAX Queries
October 30, 2013, 04:57:27 pm
I think what X is saying is that if your extension defines a new api, then it will be magically available via CRM.api ajax.
Within your api code you can do absolutely anything you want.
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Complex AJAX Queries

This forum was archived on 2017-11-26.