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.

Parents
  • 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  "www.xyz.com" 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.

  • 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", "">xyz.com");                                    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.

Reply
  • 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", "">xyz.com");                                    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.

Children
No Data