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) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Creating Relations When Creating Individual
Pages: [1]

Author Topic: Creating Relations When Creating Individual  (Read 1505 times)

will5404

  • Guest
Creating Relations When Creating Individual
August 25, 2009, 12:55:44 pm
Hi,

I'm creating a custom template for adding new individuals and one of the client requirements is the ability to setup relationships when adding a new client. For example I want to have the ability to enter who there supervisor is or what organization there part of. I know the current employer field already does something similar, however I don't understand how I can replicate it to create other relationships.

Would there be anyway to add a custom data field to a contact for example isSupervisor so when creating the supervisor relationship only people with that flag would be available for selection? Could I populate a dropdown list of data from a SQL query through Smarty or how else would I be able to make a database driven dropdown fi I went down this route?

Thanks
Will

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Creating Relations When Creating Individual
August 26, 2009, 12:06:44 am
Will:

Quote
I'm creating a custom template for adding new individuals and one of the client requirements is the ability to setup relationships when adding a new client. For example I want to have the ability to enter who there supervisor is or what organization there part of. I know the current employer field already does something similar, however I don't understand how I can replicate it to create other relationships.
You will need to make significant changes / fixes to existing code base to replicate Current Employer behavior. IMO you should skip this option.

Quote
Would there be anyway to add a custom data field to a contact for example isSupervisor so when creating the supervisor relationship only people with that flag would be available for selection? Could I populate a dropdown list of data from a SQL query through Smarty or how else would I be able to make a database driven dropdown fi I went down this route?
In v3.0 we have added custom data of type "Contact Reference" auto-complete. You can use combination of custom data of type "Select" (this will have relationship type) and Contact Reference field to create relationship. So you need to create custom of type Contact Reference and Select fields and then implement post hook that would create relationship based on selected custom data fields.

HTh
Kurund
Found this reply helpful? Support CiviCRM

will5404

  • Guest
Re: Creating Relations When Creating Individual
August 26, 2009, 09:48:02 am
Thanks for your reply. Is there anyway to filter the results returned by the auto complete form? When you make a new data entry profile does it auto generate a smarty template I can look at if I need to customize the look and feel of the form?

Thanks
will

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Creating Relations When Creating Individual
August 26, 2009, 10:01:34 am

yes, you can filter the results using a civicrm hook

check:

http://wiki.civicrm.org/confluence/display/CRMUPCOMING/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcontactListQuery

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

will5404

  • Guest
Re: Creating Relations When Creating Individual
August 27, 2009, 02:59:34 pm
Thanks for the help so far. I'm working on a custom smarty template and I'm having problems accessing my custom fields in smarty. I turned on SmartyDebug to get a list of all the available fields and when I use a custom one with:
{$form.custom_3_-1.label}

I get

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in

Is there another way I should be accessing custom fields within smarty? The end result I would like is to split some of my custom data onto multiple tabs in the new individual form. Is there any easier built in way to do this that doesn't involve editing the template its self?

Thanks
Will

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Creating Relations When Creating Individual
August 27, 2009, 06:19:08 pm

can u try

Code: [Select]
{assign var=sname value="custom_3-1"}
{$form.$sname.label}

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

will5404

  • Guest
Re: Creating Relations When Creating Individual
August 28, 2009, 07:20:58 am
That code doesn't produce an error but nothing shows up on the page. I'm getting this in Individual.tpl. Custom data is turned on on that form right now so the field does appear under the custom data tab, would trying to print its label in another spot cause it to error?

Thanks
Will
« Last Edit: August 28, 2009, 07:30:35 am by will5404 »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Creating Relations When Creating Individual
August 28, 2009, 08:37:45 am

u should check out the 3.0 edit individual form. that might be more inline with what you want

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Creating Relations When Creating Individual

This forum was archived on 2017-11-26.