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

Reply
  • 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

Children
  • @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