AnsweredAssumed Answered

User assignment problem with logic hooks

Question asked by Morel Maxime on May 27, 2014
Latest reply on Sep 18, 2016 by Ishani Lad
Hello , sorry my english is bad but I will explain my problem.

In my SugarCRM  I have a  person module and a sales module. A sale may only be made by one person . However,
  that I attribute a sale to a person only after I attribute the same sale to
another person , sugar replaces me the first person in the second for
this sale. But I want that when I assign the sale the second person sugar
displays a message "Unable : This sale is already assigned to a person
."

To highlight an error I was advised to make logic hook " after_relationship_add "

So I started to develop a hook " after_relationship_add " .
If I understand this is done in two files, the first name / custom / modules / namemodule / logic_hooks.php with it. :

<? php

    hook_version $ = 1;
    $ hook_array = Array ();

    $ hook_array [' after_relationship_add '] = Array ();
    $ hook_array [' after_relationship_add '] [ ] = Array (
        / / Processing index. For sorting the array .
        1 ,
      
        / / Label . A string value to Identify the hook .
        ' after_relationship_add Sale '
      
        / / The PHP file Where your class is located.
        'custom / modules / Sale / logic_hooks_class.php '
      
        / / The method is in the class .
        ' logic_hooks_class '
      
        / / The method to call .
        ' after_relationship_add_method '
    ) ;

? >


2nd and / custom / modules / modulename / logic_hooks_class.php with it. :

<? php

    if (! defined ( ' sugarEntry ') | | sugarEntry !) die (' Not A Valid Entry Point ');
  
    class logic_hooks_class
    {
        after_relationship_add_method function ($ bean , $ event , $ arguments)
        {
            / / Here to treatment
        }
    }

? >

However,
  I do not really know what to put in the treatment part of the second
file and I have no example on which to base myself . Do you have an example to offer me ?

In addition , these files will they automatically called by Sugar ?

thank you very much and sorry for my english

Outcomes