Results 1 to 5 of 5

Thread: Notes and Zucker Reports

  1. #1
    gkeyes is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    29

    Default Notes and Zucker Reports

    SugarCRM 5c and Zucker Reports 1.8g

    Current Code to Produce Output
    SELECT notes.date_entered, notes.date_modified, notes.name, notes.description, notes.parent_type, notes.parent_id
    FROM notes
    WHERE notes.deleted = 0
    AND notes.created_by = '$SUGAR_USER_ID'
    ORDER BY notes.date_entered;

    Header Output
    date_entered date_modified name description parent_type parent_id

    parent_type contains WHAT it is related to such as CONTACTS or LEADS OR ACCOUNTS, parent_id CONTAINS the id number of the CONTACTS or LEADS OR ACCOUNTS.

    All I want to do is ADD the LEAD or ACCOUNT or CONTACTS name to my output. I know can JOIN but I do not need all that information, just ONE, maybe two fields. I have tried IF() and IF..ELSEIF but I get errors, I assume because I am not formatting the code correclty.

  2. #2
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Notes and Zucker Reports

    Try something like this

    SELECT
    if (parent_type = 'accounts', `accounts`.name, contacts.first_name) as aname,

    notes.date_entered, notes.date_modified, notes.name, notes.description, notes.parent_type, notes.parent_id
    FROM notes
    LEFT JOIN accounts on notes.parent_id = accounts.id
    LEFT JOIN contacts on `notes`.`parent_id` = contacts.id
    WHERE notes.deleted = 0
    AND notes.created_by = '$SUGAR_USER_ID'
    ORDER BY notes.date_entered;

  3. #3
    gkeyes is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    29

    Default Re: Notes and Zucker Reports

    Ok, for the most that worked fine, it pulled for CONTACTS and ACCOUNTS, but not LEADS. This seems to be where I get stuck. The THIRD option.

  4. #4
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Notes and Zucker Reports

    Quote Originally Posted by gkeyes
    Ok, for the most that worked fine, it pulled for CONTACTS and ACCOUNTS, but not LEADS. This seems to be where I get stuck. The THIRD option.
    That was just an example

    I have modified it to include leads

    SELECT
    if (parent_type = 'accounts', `accounts`.name, if (parent_type = 'contacts', contacts.first_name, `leads`.`first_name`)) as aname,
    notes.date_entered, notes.date_modified, notes.name, notes.description, notes.parent_type, notes.parent_id
    FROM notes
    LEFT JOIN accounts on notes.parent_id = accounts.id
    LEFT JOIN contacts on `notes`.`parent_id` = contacts.id
    LEFT JOIN `leads` on `notes`.`parent_id` = `leads`.id
    WHERE notes.deleted = 0
    AND notes.created_by = '$SUGAR_USER_ID'
    ORDER BY notes.date_entered;

    obviously notes can also be added against tasks, calls, meeting ect so you need to exclude anything that is not in your if statement at the top

  5. #5
    gkeyes is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    29

    Default Re: Notes and Zucker Reports

    Thanks, I was being a newbie programmer (because I am) when I asked that last question, but your code is better then what I came up with.

    Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Zucker Reports - report on Notes entered by user
    By sbantz in forum General Discussion
    Replies: 0
    Last Post: 2008-03-18, 01:24 AM
  2. Reports
    By gquick in forum Help
    Replies: 0
    Last Post: 2007-04-26, 05:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •