New case note logic hook

I want to fire an after save logic hook when a new case note is created and saved. As notes are used by multiple modules, I wandered the best place for the login hook

1. On the case module and run on new note

2 On the notes module when parent module is Cases

was thinking to check against the parent with an on save hook against parent->type == Case

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"parent": {
"_acl": {
"fields": {
"dri_workflow_template_id": {
"create": "no",
"write": "no",
"license": "no"
},
"dri_workflow_template_name": {
"create": "no",
"write": "no",
"license": "no"
}
},
"_hash": "bf2bc9611a03b9289b43e6d828070ae2"
},
"id": "3456ce30-faf5-11ed-9bfb-0645eac4c674",
"type": "Cases",
"name": "CASE-88860"
},
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

just wandered the best place to run the hook from

  • Use an after_relationship_add logic hook 

    https://support.sugarcrm.com/documentation/sugar_developer/sugar_developer_guide_13.0/architecture/logic_hooks/module_hooks/after_relationship_add/#Arguments

    The module and related_module arguments identify the modules that are being related, if you put the logic hook in Cases

    module = Cases

    related_module = Notes

    if you put the logic hook on Notes then it will be the other way around:

    module = Notes

    related_module = Cases

    Whichever you choose it will fire when notes and cases are related one to the other.

    FrancescaS

  • thats great thanks for that

  • Hi   just a quick question, is it not possible to trigger an alert box from a logic hook using the app.alert.show. tried breaking the php flow to place in script  but then remember reading something about hooks don't have access to app

  • You would not do that from a logic hook, you would do that the controller of the view you are in.

    What is your ultimate business goal here?

  • Hey  ,

    To clarify:

    • Logic hooks are a backend technology (they run on the server)
    • App.* is a frontend technology (runs on your browser)

    The frontend "talks" to the backend via APIs.

    If you need some visual alert you would need to implement that on the frontend, either by validating just on the frontend the user input/actions, or after confirming the actions (or no actions) of the backend

    Hope it helps

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

  •   the goal is to push an update to our website when a case note has been added. and that matches some logic we have in place  When someone updates a case with a note, my logic hook sends out an update to the website which then informs the customer. I wanted to just have a popup to the sugar user just to inform them the website notice was sent successfully from the ExternalResourceClient.

  • Hi   thank you for clarifying and that was my thought. the reason for double checking is that my logic hook sends out an update to our website usingExternalResourceClient. I wanted to just let the sugar user know that this was successful  hence asking if it can be done from the logic hook as there isn't any frontend change to check against

  • Hi  ,

    Not a problem!

    If that's the case, I would then attempt to extend/customise an API that completes your website's call (given that it sounds like it might be a synchronous call either way), so that you have immediate feedback from the back-end to the front-end, and then you can display the correct message to the user based on what the API returns.

    This approach should give you what you are after.

    Cheers

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States