Results 1 to 2 of 2

Thread: Multiple note relationships. Which one is which?

  1. #1
    tobydz is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Las Vegas, NV
    Posts
    144

    Default Multiple note relationships. Which one is which?

    Here's a REALLY tricky one for my esteemed Sugar colleagues:

    I have a module that has THREE 'one-to-many' relationships under it so we can have separate notes for our clients and bank lenders. These are named:
    legal_loan_mod_notes (client)
    legal_loan_mod_notes_1 (first lender)
    legal_loan_mod_notes_2 (second lender)

    I have an after_save logic hook on the Notes module that will update a date field in the parent module with the most recent date either the client or either lender has been contacted. I can't for the life of me figure out how I can differentiate within the logic hook which type of note was created. I've run through the debugger over and over combing the variable values and I just can't seem to find a value that differentiates between the different note types..

    Help!!!

  2. #2
    tobydz is offline Sugar Community Member
    Join Date
    Mar 2011
    Location
    Las Vegas, NV
    Posts
    144

    Default [solved]

    Ok I actually found a solution. It feels like a dirty hack but whatever. I'll do my best to explain.

    During the logic hook, the bean (which in this case is the note that was created) contains variables of type "Link2" that are named after each of the notes relationships (ex. legal_loan_mod_notes_1, legal_loan_mod_notes_2, etc). Underneath the variable that corresponds to the relationship name where you created the note, you'll find another array called "beans". BEANS WILL ONLY BE UNDER THE VARIABLE NAMED AFTER THE TYPE OF NOTE YOU CREATED.... I know this sounds confusing, so let me illustrate:

    Scenario: User created a client note (legal_loan_mod_note) and not a lender note (legal_loan_mod_note_1).

    The fields in the debugger will look like:

    $bean-->legal_loan_mod_note-->beans-->[parent_module_id]
    $bean-->legal_loan_mod_note_1-->[no beans array]

    So! By checking to see if there are any values under each of the notes relationships variables, you can tell what type of note was created.

    Here's the code I used to test my theory:
    Code:
    $count1_1stLender = count($noteBean->legal_loan_mod_notes->beans);
    $count2_client = count($noteBean->legal_loan_mod_notes_1->beans);
    $count3_2ndLender = count($noteBean->legal_loan_mod_notes_2->beans);
    $count4_3rdLender = count($noteBean->legal_loan_mod_notes_3->beans);
    So if I created a client note, $count2_client would have a value of '1' and the rest would have '0'

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 2010-10-06, 01:50 PM
  2. Note for multiple Leads
    By JDogHerman in forum Help
    Replies: 1
    Last Post: 2010-02-09, 04:32 AM
  3. Tracking multiple relationships
    By StaceyG in forum Customer Support
    Replies: 0
    Last Post: 2009-05-08, 06:30 PM
  4. Replies: 1
    Last Post: 2008-01-13, 08:07 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
  •