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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Problem: "Current Employer" drop down not being filled when editing contact
Pages: [1]

Author Topic: Problem: "Current Employer" drop down not being filled when editing contact  (Read 3213 times)

stirrell

  • Guest
Problem: "Current Employer" drop down not being filled when editing contact
November 24, 2008, 02:01:58 pm
Hello all,

I have been working on a project that uses CiviCRM alongside Drupal. For the most part, it is working great. I am having a problem that I just can't seem to fix. We are using Drupal 6.6, CiviCRM 2.1.2, PHP 5.2.6 and MySQL 5.

The problem I am having is that the Current Employer drop-down option doesn't populate itself with the contact's current employer. If I choose a current employer from the drop-down list, and click "Save," the employer shows up when viewing the user's profile. But, when I go back to the edit form, the drop down field is blank.

Using the template, I tried to spit out the employer data using:

{foreach from=$form.current_employer key=bar item=foo}
    {$bar}: {$foo}<br />
{/foreach}


and the result I get is:

name: current_employer
value:
type: text
frozen:
required:
error:
id: current_employer
label: Current Employer
html:


When I look up this contact in the database, the value for Organization Name is correct and the organization id (assuming this is where the current employer is stored).

Can anyone think of why this problem may be occurring? Thank you so much for any help you can give.

Sincerely,
Scott

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 24, 2008, 02:19:41 pm
It "sounds like" the dojo comboBox "drop-down" is functional (i.e. you get a list of organizations when you click on the down-arrow icon on the right side, etc.). You can also verify that this piece is working by going directly to the search snippet URL. For Drupal sites this should be: http://<your site>/civicrm/ajax/search?org=1&name=*&start=0&count=10

Assuming this is working, then the next thing i'd do is add some debug statements to the part of the setDefaultValues() method in CRM/Contact/Form/Edit.php which is supposed to get the existing value:

Code: [Select]
// starting at line 340
        if ( $this->_action & CRM_Core_Action::UPDATE ) {
            require_once 'CRM/Contact/BAO/Relationship.php';
            $currentEmployer = CRM_Contact_BAO_Relationship::getCurrentEmployer( array( $this->_contactId ) );
// adding this debug statement
            CRM_Core_Error::debug('cE', $currentEmployer);
            $this->assign( 'currentEmployer',  CRM_Utils_Array::value( 'org_id', $currentEmployer[$this->_contactId] ) );
        }
[code]
[/code]
Protect your investment in CiviCRM by  becoming a Member!

stirrell

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 24, 2008, 07:47:04 pm
Dave,

Thank you very much for your response. I added in the code you suggested. Here is the response I get:

cE

Array
(
    [11] => Array
        (
            [org_id] => 38
            [org_name] => Rifftrax
        )

)


I actually don't work for Rifftrax but that is just the test company I put in. So it looks like it is grabbing the correct employer... I am not getting any JavaScript errors and I have tried multiple browsers.

Sincerely,
Scott

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 25, 2008, 11:05:24 am
... and you tried the snippet url and it's returning a page with listing of orgs from your site, including "Rifftrax"?

If so, not sure what could be causing the default setting to fail. I'd try using Firebug to check for other errors.
Protect your investment in CiviCRM by  becoming a Member!

stirrell

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 25, 2008, 11:18:43 am
Dave,

Yes, sorry, I did try the snippet and Rifftrax, organization id 38, is within the list:

{ name: "Rifftrax", id:"38"}

I am not too familiar with using the error checking within Firebug. I did set it to break an all errors, and it did not say display anything and the page loaded fine.

Is there anything outside of CiviCRM's admin that could cause problems with this functionality? I just have a few basic template changes for event registration, for example, and for viewing a user's past event registrations on their Drupal profile page. I am just listing out a user's past registrations using:

Code: [Select]
//initialize civicrm
civicrm_initialize(TRUE);

//required to use crm_uf_get_match_id function
require_once 'api/UFGroup.php';

//get user id from CIVICRM, using the $uid from the contact you're looking at
$userID = crm_uf_get_match_id( $user->uid );

// We will find the values from this contact using it's userID
$retrieve = array( contact_id => $userID  );

//required to use civicrm_contact_get function
require_once 'api/v2/Contact.php';
$getContact = civicrm_contact_get( $retrieve );

and

Code: [Select]
// Get the registered events information
require_once 'api/v2/Participant.php';

$params = array('participant_id' => $registeredRow['participant_id'],);

$event = & civicrm_participant_get($params);

But I don't believe I am doing anything anywhere that would write to a user's information and potentially erase it...

Sincerely,
Scott

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 25, 2008, 11:52:00 am
I sent mail to a colleague who knows more about the comboBox widget to see if he has any other ideas...
Protect your investment in CiviCRM by  becoming a Member!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 26, 2008, 09:48:47 am
Some other things to check (courtesy of Kurund Jalmi on our team):

1. Check if {$currentEmployer} variable is assigned in tpl.

2. Below url is called for setting default for current employer:

  http://civicrm/civicrm/ajax/search?sh=2&id=105

 It returns Organization Name., so we need to check if this call is made. (replace 105 with the contact ID you're testing with)
Protect your investment in CiviCRM by  becoming a Member!

stirrell

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 26, 2008, 10:53:45 am
Hello Dave,

{$currentEmployer} is displaying 38 which is the employer's id.

When going to the link suggested:

http://www.ourdomain.com/civicrm/civicrm/ajax/search?sh=2&id=38

I get a page like the attached image.

(http://www.second-cup-of-coffee.com/CRMshot.gif)

That obviously seems wrong to me...

Scott

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: Problem: "Current Employer" drop down not being filled when editing contact
November 27, 2008, 04:13:00 am
You should try:

http://www.ourdomain.com/civicrm/ajax/search?sh=2&id=38

HTh

Kurund
Found this reply helpful? Support CiviCRM

stirrell

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 27, 2008, 08:03:23 am
Whoops, I really misread that. Thanks for correcting me, Kurund. With the correct address (not doubling up civicrm) I get the employer:

Rifftrax

Which does actually seem correct.

Thanks,
Scott

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: Problem: "Current Employer" drop down not being filled when editing contact
November 27, 2008, 10:07:09 am
Can you jump on irc #civicrm , will be much faster and easier to debug your issue.

Kurund
Found this reply helpful? Support CiviCRM

iuwolf

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
November 30, 2008, 10:55:11 pm
This seems related to the issue I am having.  When I import individuals using the Employee of Organization Name, it does not populate the individuals' records with the organization name even though the record for the organization already exists. 

I found this: http://issues.civicrm.org/jira/browse/CRM-3532

is this related?
« Last Edit: November 30, 2008, 10:57:53 pm by iuwolf »

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: Problem: "Current Employer" drop down not being filled when editing contact
November 30, 2008, 10:57:59 pm
Another related thread : http://forum.civicrm.org/index.php/topic,5362.0.html

You can get the fix from: http://fisheye.civicrm.org/changelog/CiviCRM/?cs=18379

Kurund
« Last Edit: November 30, 2008, 11:25:37 pm by Kurund Jalmi »
Found this reply helpful? Support CiviCRM

stirrell

  • Guest
Re: Problem: "Current Employer" drop down not being filled when editing contact
December 01, 2008, 05:21:01 am
Kurund,

The link to the thread above, http://forum.civicrm.org/index.php/topic,5362.0.html, solved the problem for me. Thanks so much to all the help you all provided. It is very much appreciated!

Sincerely,
Scott

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Problem: "Current Employer" drop down not being filled when editing contact

This forum was archived on 2017-11-26.