Show notification that a logic hook triggered

I need to show a notification that some fields were automatically updated by a logic hook.

When saving an account or contact, it checks for certain flags to be set across all contacts. If it is the only contact attached to an account, the flags get set automatically.

This behaviour is sometimes unexpected when in the contact view, because the flags get set on save, but the reason is not obvious. How do I show a popup notification (similar to error/success messages) when the flags have been set?

Parents
  • Hi Derick van Niekerk

    Once try this and let me know:

    Put this code before end of your logic hook function i.e ( " } " ) 

    SugarApplication::appendErrorMessage('<span style="color: green; display: block; width: 100%; font-size: 15px; text-align: center; margin-top: 15px;">Record saved successfully!</span>');

    if you want to check Database Value ( i.e Before values ) and Update Values printing in GLOBAL log to do so:

    $GLOBALS['log']->fatal("More results " . print_r($beans, True));

    Good Luck.

    Hope this Helps.

    Best Regards

    S Ramana Raju

  • @Ramana Raju Santhana The SugarApplication::appendErrorMessage() was more or less what I was looking for, thanks!

    @Dennis Wangerin I am beginning to think my use of a logic hook for this purpose may not be the best way - precisely because of how sidecar is built with these kinds of notifications in mind. However, logic hooks are an elegant way to enforce the business logic whether we are using the API, Connectors or the UI. Unfortunately I have not found an elegant way to communicate the result of a before_save logic hook to Sidcar unless I throw an error, resulting in the save process stopping.

    I wish there were a solution somewhere between these two - where I could add a notice message to a message queue or something similar.

    Thanks for the answers!

    Derick

  • @Ramana Raju Santhana SugarApplication::appendErrorMessage() does not actually seem to have any effect .

    I have added it before the logic hook exits. If I trace the code with a debugger, I can see that the line gets executed without error, but it does not actually display any message other than the standard 'successfully saved' message.

  • Derick van Niekerk

    If you only want to check your logic hook is trigger or not for this no need of any notification,  you can check it using GLOBALS log to do so:

    $GLOBALS['log']->fatal("My Logic hook is triggered");
    $GLOBALS
    ['log']->fatal("More results " . print_r($beans, True));

    Put the above line in your logic hook and once saving of record is done, then check it in sugarcrm.log file.

    If your logic hook executed then you are able to see your log message " My Logic hook is triggered" & also it will print all your $beans values. I think this is the only way we can get.

    Let me know for further Help.

    Best Regards

    S Ramana Raju

  • The logic hook is triggered and works well but logging does not help to notify a current user about the actions taken. 

    SugarApplication::appendErrorMessage() seems to be what I'm looking for because it would display a message to the current user... Unfortunately it doesn't display anything. I want a notice to display on the screen to tell the user what the logic hook just did. Otherwise flags seem to reset themselves and no reason is given. It is unlikely that an end user would notice the logs

    Derick

Reply
  • The logic hook is triggered and works well but logging does not help to notify a current user about the actions taken. 

    SugarApplication::appendErrorMessage() seems to be what I'm looking for because it would display a message to the current user... Unfortunately it doesn't display anything. I want a notice to display on the screen to tell the user what the logic hook just did. Otherwise flags seem to reset themselves and no reason is given. It is unlikely that an end user would notice the logs

    Derick

Children
No Data