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 »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • View Query Not matching User???
Pages: [1]

Author Topic: View Query Not matching User???  (Read 1557 times)

cameron

  • Guest
View Query Not matching User???
July 27, 2009, 03:36:31 pm
Hi,

I have tried everything I can possbily think of but I still get a double result from my view query. Please see details below?? I am hopeing it is something silly that i have missed??? (Sorry to double post - http://forum.civicrm.org/index.php/topic,8963.0.html - just felt it needed to stand out beyond the previous thread)

I would so very much appreciate help.

Below is what comes out of the View in the Drupal Panel section (overriding core Drupal Profile). Please note that the 2nd entry is not displaying the address??. Also please note that the double entry first occurs when I add any of the location/address/Postal code fields to the view. i.e.This does not occur if I only list fields for Name and Phone (Primary). But it does occur if I try to add Phone (mobile) ???

View display -

Contact: Cameron
Phone: 026688XXXX
Address: 5X Terania St
Contact: Cameron
Phone: 026688XXXX
Address:

This is the query result in the View -

SELECT DISTINCT(civicrm_contact.id) AS id,
   users_civicrm_uf_match__civicrm_contact.last_name AS users_civicrm_uf_match__civicrm_contact_last_name,
   users_civicrm_uf_match__civicrm_contact.id AS users_civicrm_uf_match__civicrm_contact_id,
   civicrm_phone.phone AS civicrm_phone_phone,
   civicrm_address.street_address AS civicrm_address_street_address
 FROM visionar_civicrm.civicrm_contact civicrm_contact
 LEFT JOIN visionar_civicrm.civicrm_uf_match civicrm_uf_match ON civicrm_contact.id = civicrm_uf_match.contact_id
 LEFT JOIN users users_civicrm_uf_match ON civicrm_uf_match.uf_id = users_civicrm_uf_match.uid
 LEFT JOIN visionar_civicrm.civicrm_uf_match users_civicrm_uf_match__civicrm_uf_match ON users_civicrm_uf_match.uid = users_civicrm_uf_match__civicrm_uf_match.uf_id
 LEFT JOIN visionar_civicrm.civicrm_uf_match users_civicrm_uf_match_users_civicrm_uf_match__civicrm_uf_match ON users_civicrm_uf_match.uid = users_civicrm_uf_match_users_civicrm_uf_match__civicrm_uf_match.uf_id
 LEFT JOIN visionar_civicrm.civicrm_contact users_civicrm_uf_match__civicrm_contact ON users_civicrm_uf_match__civicrm_uf_match.contact_id = users_civicrm_uf_match__civicrm_contact.id
 LEFT JOIN visionar_civicrm.civicrm_phone civicrm_phone ON civicrm_contact.id = civicrm_phone.contact_id
 LEFT JOIN visionar_civicrm.civicrm_address civicrm_address ON civicrm_contact.id = civicrm_address.contact_id
 WHERE users_civicrm_uf_match__civicrm_contact.id = 1

And here is the entire exported View -

Code: [Select]
$view = new view;
$view->name = 'Contact_Details';
$view->description = 'Contact Details';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'civicrm_contact';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'drupal_id' => array(
    'label' => 'Drupal User',
    'required' => 0,
    'id' => 'drupal_id',
    'table' => 'civicrm_contact',
    'field' => 'drupal_id',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('fields', array(
  'last_name' => array(
    'label' => 'Contact',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'link_to_civicrm_contact' => 0,
    'exclude' => 0,
    'id' => 'last_name',
    'table' => 'civicrm_contact',
    'field' => 'last_name',
    'relationship' => 'drupal_id',
  ),
  'phone' => array(
    'label' => 'Phone',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'phone',
    'table' => 'civicrm_phone',
    'field' => 'phone',
    'relationship' => 'none',
  ),
  'street_address' => array(
    'label' => 'Address',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'street_address',
    'table' => 'civicrm_address',
    'field' => 'street_address',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'id' => array(
    'default_action' => 'ignore',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'fixed',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'id',
    'table' => 'civicrm_contact',
    'field' => 'id',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'drupal_id',
    'default_options_div_prefix' => '',
    'default_argument_user' => 0,
    'default_argument_fixed' => '',
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'panel' => 0,
      'civicrmactivity' => 0,
      'page' => 0,
      'profile' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('distinct', 1);
$handler = $view->new_display('panel_pane', 'Content pane', 'panel_pane_1');
$handler->override_option('pane_title', '');
$handler->override_option('pane_description', '');
$handler->override_option('pane_category', array(
  'name' => 'View panes',
  'weight' => 0,
));
$handler->override_option('allow', array(
  'use_pager' => FALSE,
  'items_per_page' => FALSE,
  'offset' => FALSE,
  'link_to_view' => FALSE,
  'more_link' => FALSE,
  'path_override' => FALSE,
  'title_override' => FALSE,
  'exposed_form' => FALSE,
));
$handler->override_option('argument_input', array(
  'uid' => array(
    'type' => 'panel',
    'context' => 'term.tid',
    'panel' => '0',
    'fixed' => '',
    'label' => 'User: Uid',
  ),
));
$handler->override_option('link_to_view', 0);
$handler->override_option('inherit_panels_path', 0);
« Last Edit: July 29, 2009, 06:37:25 am by caminoz74 »

cameron

  • Guest
Re: Double User Results in View Query???
July 28, 2009, 08:04:36 am
Ok... so a somewhat messy move but I have limited the 'view pane' to 1 item so it will only list the users details... this works when I do the live preview!!

When I go to the Drupal Profile Panel though I have inserted the content pane to display the view and indicated the 'CiviCRM Contacts: contact' to be 'User ID' and it works fine for the first contact however every other contact displays the data of the contact after it not its own??? This would indicate to me that the is a phantom user in the drupal side of the system however I have check and all records are accounted for???

perhaps this is tied to the original problem of double user results?

Very Confusing.....

cameron

  • Guest
User data does not match in View
July 29, 2009, 04:43:52 am
I have just reinstalled the whole site from scratch and the field in the view, in the panel, in the overridden Profile, still displays the result from the next user, not its own. This is for every user except the admin (user/1).

I am completely fumbbled and at a loss... pleeeeeaaaaassssseeeee can someone help me!!! If I cannot get this little thing working the whole site concept is stuffed....

I will keep trying myself and post if I find anything.... maybe its just me and no-one else has had this happen?
« Last Edit: July 29, 2009, 06:08:54 am by caminoz74 »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: View Query Not matching User???
July 29, 2009, 12:06:08 pm
You might want to engage some help from another developer / consultant : http://civicrm.org/professional
I believe Jim Taylor at Rooty Hollow has a fair amount of experience with views (as one option).
Protect your investment in CiviCRM by  becoming a Member!

cameron

  • Guest
Re: View Query Not matching User???
July 31, 2009, 03:36:23 am
Thanks Dave, I will contact as suggested.... However

I think i have tracked down the main issue that makes every other users data after me (admin/1) apear as the next users data. What we have is a mismatch between the Drupal userID and the CiviCRM userID.

To explain further...

Drupal user/1 - Admin MATCH CiviCRM User 1 - Admin/Me
Drupal User/2 (No user details) GOES STRAIGHT TO Drupal User/3 - Trying to find CiviCRM User 3

I remember somewhere that when I set up the Panel to override the Drupal User Profile (either manual or via APK) it took the User/2 page... which would explain why there is no user details locked to user/2. Sooo.... everything worked fine up to and including the View but when I test the Panel thats where is gets confused.

In the Panel I have to select CiviCRM Contacts: Contact TO 'User ID' or is still lists multiple (all) users data. And it actually works to produce the correct result for at least my data. But when I test User 2 in the Panels Live Preview, I get all users data (but not linked to a particular Drupal user). When I then test User 3, I get the link to the Drupal User but not the matching CiviCRM data.

So... this is where I am at... I think I need to find where the Drupal User/2 page has been stolen to?!

Who's got a clue?
« Last Edit: July 31, 2009, 04:00:20 pm by caminoz74 »

cameron

  • Guest
Re: View Query Not matching User???
July 31, 2009, 04:35:51 am
A clue!

I have previously been setting up a View type: CiviCRm Contacts

I have just tried to set up a View type: User... and it fully works.

One problem, the CiviCRM fields available in this type of view do not include address details??? WHY NOT IS THE QUESTION?

I have yet to try custom ccrm fields....

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • View Query Not matching User???

This forum was archived on 2017-11-26.