Skip to main content

GROWING AND SUSTAINING RELATIONSHIPS

GROWING AND SUSTAINING RELATIONSHIPS
Close
Stacy Liou

Implementor, Developer, Trainer

elMobile Inc.

http://www.elmobile.com

As developers for various OpenSource CRM applications, we learned a lot from CiviCRM on its scalability and ease of customization.
CiviCRM community is truly organic cultivating growth for users and developers.
We wish to continue learning with CiviCRM and to tackle future challenges with CiviCRM.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Allen Shaw

DEVELOPER

NS WEB SOLUTIONS

http://nswebsolutions.com

I'm quite impressed with the responsiveness of the CiviCRM community, both from the core developers and many experienced users who have quickly provided answers and ideas in areas where I just needed that extra insight, or where we needed to do something totally new. After several years working with open source software, I'm finding the CiviCRM community to be the most responsive and helpful I've seen.

We make CiviCRM one of our primary offerings because it just provides so much right out of the box that our clients need, without a line of custom code. And when we need to extend it for the clients' unique needs, the APIs and programming hooks let us add in features that would be impossible in some other systems. This means we can provide great value to our clients with quick turnaround times and reasonable budgets, which is great for our clients and for us.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Tim Otten

DEVELOPER AND IMPLEMENTER

CiviCRM

http://civicrm.org
GROWING AND SUSTAINING RELATIONSHIPS
Close
Coleman Watts

End-user and Developer

Woolman Sierra Friends Center

http://woolman.org

If it weren't for CiviCRM we'd be using at least 5 different
systems for Woolman: one for donor management, another for email newsletters, a third for our school enrollment, a fourth for our summer camp registration, and then a whole bunch of spreadsheets for keeping track of things like event attendance, prospective students, CSA memberships, etc. And of course none of those systems would talk to each other or make it possible to get a whole picture of the many ways one person might participate in our education center's activities. Migrating all of our scattered data and disparate systems to CiviCRM was a long and challenging process, but the results have been more than worth it. Our ability to track and report on our programs has improved dramatically, while the burden on staff to do data entry has been greatly reduced, and our participants are happy that they can now register/enroll online rather than mailing or faxing paper forms.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Kurund Jalmi

Developer, Implementor

Web Access India Pvt. Ltd.

http://webaccessglobal.com

I have been part of CiviCRM project from the beginning and feels great to see how it has grown over the years.
I am glad to be associated with such a wonderful open source project and an awesome community around it.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Sarah Gladstone

Implementor, Developer

Pogstone, Inc.

http://pogstone.com

I have been involved in the CiviCRM community for over 4 years, and enjoy implementing and programming CiviCRM for a variety of non-profits. I have been amazed at the rapid pace of innovation delivered with each new release, and CiviCRM's flexibility in being able to accommodate a variety of requirements. I have learned a lot about CiviCRM by participating in CiviCon, online forums, and CiviCRM book sprint.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Eileen McNaughton

Developer and End-user

Fuzion

http://fuzion.co.nz

CiviCRM has one of the most active and friendliest communities I have come across. From initial tentative forum posts I was encouraged into engaging more actively through IRC and directly with other groups & individuals and am now happy to count many community members as friends. I recently found an article on the web that said if you post a question about CiviCRM anywhere on the web Lobo will post an answer within a few hours. It often feels like that is true.

One of the most valuable way in which the community supports me is by allowing me to bounce my ideas around and often someone is able to suggest an approach which is better than mine.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Jake Martin White

Implementor, Developer

PeaceWorks Technology Solutions

http://www.peaceworks.ca

PeaceWorks provides technology solutions for not-for-profit organizations. CiviCRM fills an important niche among our clients who need a flexible, comprehensive, user-friendly, web-integrated CRM solution.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Ken West

End-user, Administrator

City Bible Forum

http://citybibleforum.org

City Bible Forum is an Australian not-for-profit Christian organisation. We need to communicate effectively with our constituents, and CiviCRM gives us a comprehensive set of tools for managing relationships. Interestingly, we often find that new features are being added just as our need for those features is becoming apparent. It's the right fit for us.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Abril Rocabert

Administrator and End-user

http://www.alternativasycapacidades.org

CiviCRM is a powerful tool that could be really useful for many non-profits in Mexico.
Unfortunately the community is very small in my country. I hope that in the next years the community expands around Latin America.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Paul Keogan

Implementor

BackOfficeThinking

http://www.backofficethinking.com

CiviCRM allows us to bring all benefits and capabilities of a large commercial CRM and
donor management system to medium and large non-profits at a fraction of the cost. CiviCRM also allows smaller non-profits to benefit from an integrated solution for donor management, events, bulk email, etc. substantially increasing their effectiveness as compared to managing a variety of nonintegrated software and spreadsheets. Thanks to a strong CiviCRM community, CiviCRM’s functionality continues to advance and CiviCRM’s market continues to grow rapidly.

GROWING AND SUSTAINING RELATIONSHIPS
Close
Katy Jockelson

Implementor, administrator

Third Sector Design

http://thirdsectordesign.org

We work with non-profits to help them use and understand Civi. It's such an important tool for these organisations and it's great to see people using it in different and interesting ways. Using and working with Civi is made so much more fun and useful by the enthusiastic and talented community surrounding it.

LOGIN | REGISTER
  • Create new account
  • Request new password

Search form

  • BLOG
  • DEMO
  • Find An Expert
  • NEED HELP
  • SUPPORT US
  • DEVELOPER RESOURCES
CiviCRM Community Site logo CiviCRM Community Site
  • WHAT IS CIVICRM
    • Community
    • Case Studies
    • Experts
    • Contributors
    • Core Team
    • Licensing
    • Contact Us
  • WILL CIVICRM MEET YOUR NEEDS?
    • Contacts
    • Contributions
    • Communications
    • Peer-To-Peer Fundraisers
    • Advocacy Campaigns
    • Events
    • Members
    • Reports
    • Case Management
  • GET STARTED
    • Evaluate Your CRM Needs
    • Evaluate CiviCRM Features
    • Read Books
    • Demo CiviCRM
    • Download CiviCRM
    • Find An Expert
  • PARTICIPATE
    • Join the CiviCRM Community
    • Read Our Blog
    • Community Forum
    • Attend a Training or Meetup
    • Make It Happen
    • Contribute
    • Become A CiviCRM Developer
    • Issue Tracker
    • Help with Documentation
    • Translate

You are here

Home » Blogs » xavier's blog

Blog

  • Architecture Series
  • CiviCampaign
  • CiviCase
  • CiviCon
  • CiviContribute
  • CiviCRM
  • CiviCRM API
  • CiviCRM Code Sprint
  • CiviCRM Meetups
  • CiviCRM Release
  • CiviCRM Solutions (case studies and user stories)
  • CiviCRM Team
  • CiviCRM Training
  • CiviCRM v1.6
  • CiviCRM v1.7
  • CiviCRM v1.8
  • CiviCRM v1.9
  • CiviCRM v2.0
  • CiviCRM v2.1
  • CiviCRM v2.2
  • CiviCRM v2.3
  • CiviCRM v3.0
  • CiviCRM v3.1
  • CiviCRM v3.2
  • CiviCRM v3.3
  • CiviCRM v3.4 and v4.0
  • CiviCRM v4.1
  • CiviCRM v4.2
  • CiviEvent
  • CiviMail
  • CiviMember
  • CiviMobile
  • CiviPledge
  • CiviReport
  • Documentation
  • Drupal
  • Extensions
  • Finance and Accounting
  • Interface Design and Layout Standards
  • Internationalization and Localization
  • Joomla
  • Older Versions
  • Schools
  • WordPress

How to customise a contact reference custom field

Submitted by xavier on June 11, 2010 - 07:18

Relationship are a natural way of storing relations between contacts. However, it doesn't work so well if you have several hundreds of related contacts as the realationship tab becomes unreadable quite quickly.

One of our client needed to associate each individual in their base to a local branch (we implemented a nice geo lookup based on the postal code to identify the local branch, but that's another story). It means that each local branch has 1000th of individuals. This could happen in other situations, for instance to keep a relationship between a "main teacher" and each pupil or who is the latest volunteer that contacted each person in a GOTV/ Canvassing campaign...

We choose to store that relation as a custom field of the type "contact reference". Each individual has a new field "nearest local branch", that is a reference to an organisation (the local branch).

It works fine and you have a nice autocomplete field, like the search field in the top left corner in the menu and you can select the branch. However, the list contains all the contacts, not only the branches.

To improve that, we replaced the default template (templates/CRM/Contact/Form/Edit/CustomData.tpl) that displays the custom field by a custom one (configure your civicrm and put it in a custom directory, don't modify directly the template provided).

In our case, the subset is the list of organisations that belong to a specific group "local branches" (id 71).

  jQuery(document).ready(function($)  
  {  
    var customGroup = "#Your_custom_field_set_id";//depends on the name you gave
    var groupID = 71;//depends on your install

    // the id of the custom fields change between calls, that's always in the form
    // custom_{id of the field}_{a number that changes based on the moon's phase or something}. 
    //In our case, the custom field id is 42, so the id is going to be custom_42_, custom_42_2, custom_42_5 ...

    customid=$(customGroup + " input:first").attr('id');
    t=customid.split("_");
    suffix =  "_"+t[2];

    //first take out the default autocomplete that contains all the contacts,
    // and replaces it with one that contains only a subset,
    $("#custom_42"+suffix).unbind().autocomplete( 
      "/civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=organization&group[71]=1",
    {
     dataType:"json",
     extraParams:{sort_name:function () {return $("#custom_42"+suffix).val();}},
     formatItem: function(data,i,max,value,term){ return value;},
     parse: function(data){
         var acd = new Array();
         for(cid in data){
           acd.push({ data:data[cid], value:data[cid].sort_name, result:data[cid].sort_name });
         }
         return acd;
     },
       width: 500,
       delay:50,
       max:200,
       mustMatch: true,
       autoFill:true,
       selectFirst: true
   )};
)};

By simply changing the url of the ajax callback, you can pretty much restrict the list to whatever you need, eg:

For the GOTV, it could be the individuals that are tagged either volunteer (tag id= 42) or staff (tag id=43)
- /civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_type=Individual&tag[42]=1&tag[43]=1

For the teachers, it could be the contacts of the subtype teacher that leave in france
- /civicrm/ajax/rest?json=1&fnName=civicrm/contact/search&contact_sub_type=teacher&country=france

Pretty neat, isn't it ?

For the next release, I'm working on a new jquery plugin that would make it even easier:

$("#custom_42"+suffix).unbind().crmAutocomplete( {
  "contact_type" : "organization",
  "group[71]" : 1});

To be continued...

And as it's been bloged about already, you can use this autocomplete and ajax features in your profile fields as well.

X+

P.S. This example works on a drupal install with clean url and installed at the root of your domain, you might need to adjust the url accordingly.

  • xavier's blog
  • Log in or register to post comments

Comments

This is super cool and useful ...

Permalink Submitted by Dave Greenberg on June 11, 2010 - 13:58

Might be good to add a link to this blog post on the wiki in the custom fields section and / or a copy of this in the Developer -> Customizing section and / or add as an example in the book dev section!

  • Log in or register to post comments

contactListQuery hook

Permalink Submitted by lcdweb on June 11, 2010 - 14:14

Isn't this what the contactListQuery hook is designed for?
http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcontactListQuery

Or if not -- or if the hook didn't meet your need -- can you explain the difference between your solution and using the hook to control what's available in the list?

  • Log in or register to post comments

KISS

Permalink Submitted by xavier on June 12, 2010 - 01:47

Well, I'd argue that it's much easier to add a few lines of jQuery in a template than having to develop a module and add the hook and find the right sql query.

Moreover, the ajax solution is using the power of the api, ie. you have as many filters as you want, essentially for free. I takes 10 seconds to switch from filter "all the contact subtypes teacher & leaving in CA and that are tagged experienced and that belong to the group supervisors or the group elementary teachers" to "organizations in france that have the custom field 'magic pony' set to pink".

With the hook, you have to know civicrm db structure to create that request, and it takes way longer to build it than set a few params to an api call, that's much harder to switch between criteria, and because the db structure changes between versions, an upgrade might break up your sql query, much less likely with the api.

The only benefit of that hook is that you can do queries that aren't available in the api. I personally would in that case create a new custom API instead of the hook, so it is usable as well from the rest api, and crmAPI and other templates.

tl; dr; : me no liking sql, me liking api ;)

  • Log in or register to post comments

And, filter based on other fields' values

Permalink Submitted by xavier on June 12, 2010 - 05:51

Oops, almost forgot something that is really funky: you can use the value of another field in the form to filter further the list.

We did use for mepwatch.eu and when you set the country field for a candidate, the list of parties where restricted to the ones from that country, direct from the browser, without any additional request or page reload.

in 2 lines of jQuery.

X+

  • Log in or register to post comments

The preferred way to do event

Permalink Submitted by dalin on June 12, 2010 - 19:44

The preferred way to do event binding, and anything else that doesn't affect the appearance of the visible portion of the page is to use
$(window).load(function(){});
rather than
$(document).ready(function(){});
This trick makes your JavaScript run after the page is completely finished rendering whereas using document.ready will delay page rendering. This is most important for anything that does an HTTP request (which isn't the case here).

  • Log in or register to post comments

Good point

Permalink Submitted by xavier on June 14, 2010 - 00:07

Have to say I put it into ready instead of load without thinking about it and in general your point is very good advice.

In that case, as it's about undoing something that has an impact on the GUI (the autocomplete adds an icon on the field...) and that it doesn't take long (no request on the network to wait for) I'd leave it there, but definitely going to work as well in the load.

  • Log in or register to post comments

CIVICRM


GROWING AND SUSTAINING RELATIONSHIPS

WHAT IS CIVICRM
  • Community
  • Case Studies
  • Experts
  • Contributors
  • Core Team
  • Licensing
  • Contact Us
WILL CIVICRM MEET YOUR NEEDS?
  • Contacts
  • Contributions
  • Communications
  • Peer-To-Peer Fundraisers
  • Advocacy Campaigns
  • Events
  • Members
  • Reports
  • Case Management
GET STARTED
  • Evaluate Your CRM Needs
  • Evaluate CiviCRM Features
  • Read Books
  • Documentation
  • Demo CiviCRM
  • Download CiviCRM
  • Find An Expert
PARTICIPATE
  • Join the CiviCRM Community
  • Read Our Blog
  • Community Forum
  • Attend a Training or Meetup
  • Make It Happen
  • Contribute
  • Become A CiviCRM Developer
  • Issue Tracker
  • Help with Documentation
  • Translate