Link Documents to Opportunity via Logic Hook

I am trying to link documents from the cases module to to the opportunity module via a logic hook and looking for a code snippet to help.

  • Hi

    The code may looks like that:

    $bean->load_relationship('documents');
    $doc_id_list = $bean->documents->get();
    $opp = BeanFactory::getBean('Opportunities', $opp_id);
    $opp->load_relationship('documents');
    $opp->documents->add($doc_id_list);
    

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hi 

    It is not the only option to make direct custom coding for Sugar if you need custom logic hooks in Sugar

    Logic hooks could be designed visually with Logic Builder for Sugar - just explain the logic and get ready-to-use upgrade safe Sugar extension - zip to upload via Module Loader

    Below is the example - on new Opp created for the Account, relate all the Documents for all the Cases registered against Account to the newly created Opp.
    To read the logic sequence, just follow the white line.
    The ready-to-use zip that implements the logic hook is attached below, you may use it

    Cheers,
    Dmytro



    z20200917_flowchart_lb5f633e54d0ee56_91412322.zip