How to push data to external system using module logic hook

Hi All,

I need to know is it possible to push data from  sugar to external system using logic hook.I know web logic hook is enough  to push data even though i have an special requirement to push data using logic hook. I like to know is it any way to achieve this.

  • Hi Sino Thomas,

    Logic Hooks can only be used within the environment. If you want to send data that we have in logic hooks to the external environment then you can call the curl request. 

    It can also pass via the create.js, record.js according to your need. 

  • Hello Maryam,

    Thanks for your solution.

    I found the following suggested ways from the internet.

    1)Create a logic hook on the module and push data to External system or ESB. May be curl request is call in the logic function.

    2)Create a logic hook on the module that queues a background job to call the External system or ESB.

    Let me know which one is a feasible solution.

  • Hi Sino,

    Can you send me the reference from where you found these solutions? I don't know in which context they discussed ESB and Job Queues, according to my information they both are used at the OS level in general, these are not specific with SugarCRM. 

    So I can't say anything about the above approaches you discussed because I think they will complicate the environment and implementation as well.

    I have already faced this type of situation where I need to send the bean data to some external website. So I did it in create.js and record.js in which I can access my data and send it to my external party. 

  • Hello Maryam,

    Following is the context behind the suggestions

    One of our client need integrate Sugar to the existing system.They need to push the Assigned Leads to the existing external system.The integration can be completed by the using the API of external system or using the ESB which is already integrated in the external system.

    So this the context behind the suggestions.

  • If you want to send the Lead data to external system when Lead will create/save then the API or anything will use by the Sugar side not by the external system side. 

    So what you can do is you can create a form in the create.js in a function which triggers after saving of bean, populate the data of bean in fields of a form and then click submit which will hit the URL to the external system suppose  "" and then you can get the data. 

  • Hello Maryam,

    Thank you very much for your support and suggestion.

     I will try the method which you suggested.

    Also if you have get any idea about the above suggested methods,Let me know.

    Thanks and Regards,

    Sino Thomas.

  • Hi Sino Thomas,

    While I think this architectural discussion might be a little complex and there are many nuances, I would try to give you some pointers to help out.

    I would definitely follow your approach. Between the logic hook that talks directly to the external system and queueing a job via a logic hook, that then would talk to the external system I would definitely recommend the second approach.

    That's how web logic hooks work as well. At least you would not have the users experience depending on the speed of the secondary system, while if you had logic hooks talking directly to the external system (or ESB/middleware), the system would have to wait for the communication to the external system to be completed, before responding to the user.

    Another alternative is also to look into Sugar Integrate, our latest iPaaS system integration product. Especially if you are planning to have many integrations, it is going to be really helpful to have a central system with a standard data mapping layer between all the systems, that you can rely upon.

    In regards to "UI based integrations", normally I would only use those within custom dashlets. The typical use-case is to see relevant information (from external systems) contextual to the record you are looking at in the UI. Eg: I am looking at an Account, and I need to know that the Account has paid all their invoices. The dashlet could make a real-time call to the accounting/ERP software and retrieve that information. For pushing information outbound they are normally not recommended also because they would not trigger in case of Sugar Mobile, or any other UI leveraging Sugar's API. Logic hooks instead would still trigger.

    Hope it helps and good luck! 

  • In the "saveAndClose" function of create.js, you can create a form and send it to 3rd party. That is the sample code.

                                       var form = $('<form></form>');                                     form.attr("method", "post");                                    form.attr("action", "">");                                    form.attr("target", "_blank");                                    var field = $('<input></input>');                                     field.attr("type", "hidden");                                    field.attr("name", 'email');                                    field.attr("value", data['email']);                                    form.append(field);                                     var field1 = $('<input></input>');                                    field1.attr("type", "hidden");                                    field1.attr("name", 'category');                                    field1.attr("value", data['cat']);                                    form.append(field1);                                     var field2 = $('<input></input>');                                    field2.attr("type", "hidden");                                    field2.attr("name", 'type');                                    field2.attr("value", data['type']);                                    form.append(field2);                                     // The form needs to be a part of the document in                                    // order for us to be able to submit it.                                    $(document.body).append(form);                                    form.submit();                                }, this),                                error: function (error) {                                    console.log("API Failed");                                },                            });

    I am populating the data in the hidden type fields so that on the other side I can access them without any disturbance.

  • Hello Enrico Simonetti

    Your architectural discussion very helpful for me.

    based on my suggested methods what I conclude is 

    Create a logic hook on the module that queues a background job to call the External system or ESB.

    Is more recommend  approach. Is it my understanding is right ?