Results 1 to 5 of 5

Thread: Fill related field in logic hook

  1. #1
    fmarambio is offline Member
    Join Date
    Jun 2011
    Posts
    5

    Default Fill related field in logic hook

    Hi there,

    I have a logic hock that creates a new bean (Invoice). One of the fields I have to assign a value is a related field (Account). I manage to have the account ID but I dont have a clue how to assign the value to this related field so it becomes a link to the account.

    Anyone can help?

    Thanks

    Francisco.

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Fill related field in logic hook

    Hi Francisco

    Please, clarify in details your needs.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    fmarambio is offline Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Fill related field in logic hook

    Andre:

    From the ProjectTask module I have a logic hook that it triggers when the projecttask is in status = Complete. The logic hook has to create a new invoice and fill this fields:

    My problem is how to fill this fields from logic hook so I get this result:

    Thanks you for your help!
    Attached Images Attached Images   

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Fill related field in logic hook

    Hi Francisco

    Thank you for clarify your needs, now I fully understand.
    I "believe" the Project is related to an Account, Opportunity and a Contact, so you are able to fetch the related ids without big deal:

    retrieve the Project;
    under project load relationship to Accounts, Contacts and Opportunities and fetch the related ids
    PHP Code:
    $project->retrieve($bean->project_id);

    $project->load_relationship('accounts');
    $account_id_list $project->accounts->get(); // this returns an array containing all related Accounts, hopefully there is only one.
    $account_id array_shift($account_id_list);

    $project->load_relationship('contacts');
    $contact_id_list $project->contacts->get();
    $contact_id array_shift($contact_id_list);


    $project->load_relationship('opportunities');
    $opportunity_id_list $project->opportunities->get();
    $opportunity_id array_shift($opportunity_id_list); 
    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  5. #5
    fmarambio is offline Member
    Join Date
    Jun 2011
    Posts
    5

    Default Re: Fill related field in logic hook

    Andre:

    Thanks for your help.

    I might explain wrong. In my case I have to create an invoice record from scratch, so I dont have the id, therefore It doesnt have relationships, what I have to do is relate this new invoice to an opportunity, account and contact (all these are related fields).

    What I want to figure it out is that if for example my related field is contact_c , I have to assign a value to related this field to a contact? I have to do:

    PHP Code:
    $contact_c $contact_id 
    Thanks very much for your help, and sorry for so many questions im new in this

    Regards

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 2010-09-10, 04:33 PM
  2. Logic hook for calculation with fields from related module
    By Systems Navigator in forum Developer Help
    Replies: 2
    Last Post: 2010-08-20, 08:34 AM
  3. Replies: 0
    Last Post: 2010-07-16, 02:01 PM
  4. Getting field name of relationship for logic hook
    By jhermiz in forum Developer Help
    Replies: 1
    Last Post: 2008-12-16, 03:44 PM
  5. Showing name of related item in list view - logic hook?
    By dogfuel in forum Developer Help
    Replies: 2
    Last Post: 2008-01-04, 11:48 PM

Tags for this Thread

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
  •