{"id":276,"date":"2020-04-27T18:17:02","date_gmt":"2020-04-27T18:17:02","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=276"},"modified":"2020-09-08T14:51:15","modified_gmt":"2020-09-08T09:21:15","slug":"executing-logic-hook-in-suitecrm-sugarcrm-rest-api","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/","title":{"rendered":"Executing Logic Hook in SuiteCRM\/SugarCRM REST API"},"content":{"rendered":"\n<p>The Logic Hook framework allows us to&nbsp;execute custom code on system&nbsp;events such as when creating, editing, and deleting records. A logic hook is defined in a file as PHP function which execute when an event is triggered. For more detail about SuiteCRM logic hook, see&nbsp;<a href=\"https:\/\/docs.suitecrm.com\/developer\/logic-hooks\/\">here<\/a>.<\/p>\n\n\n\n<p>It is important to note that there are various ways to implement a logic hook, but only some logic hooks are triggered when using REST API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Logic hook trigger with REST API<\/h2>\n\n\n\n<p>Teh following Logic Hooks are trigger from REST API call.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><em>after_delete<\/em>: Fired when a record is deleted.<\/li><li><em>after_relationship_add<\/em>: Fired after a relationship is added between two records. Note that this may be called twice, once for each side of the relationship.<\/li><li><em>after_relationship_delete<\/em>: Fired after a relationship between two records is deleted.<\/li><li><em>after_restore<\/em>: Fired after a record is undeleted.<\/li><li><em>after_retrieve<\/em>: Fired after a record is retrieved from the DB.<\/li><li><em>after_save<\/em>: Fired after a record is saved. Note that due to some peculiarities some related modules may not be persisted to the database. The logic hook is fired within the SugarBean classes save method. Some implementing classes may save related beans after this method returns. A notable example of this is the saving of email addresses in Company modules.<\/li><li><em>before_delete<\/em>: Fired before a record is deleted.<\/li><li><em>before_relationship_add<\/em>: Fired before a relationship is added between two records. Note that this may be called twice, once for each side of the relationship.<\/li><li><em>before_relationship_delete<\/em>: Fired before a relationship between two records is deleted. Note that this may be called twice, once for each side of the relationship.<\/li><li><em>before_restore<\/em>: Fired before a record is undeleted.<\/li><li><em>before_save<\/em>: Fired before a record is saved.<\/li><li><em>handle_exception<\/em>: Fired when an exception occurs in a record.<\/li><li><em>procrss_record<\/em>: Trigger &nbsp;when viewing record list from web portal<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Avoid&nbsp;<code>process_record<\/code>&nbsp;logic hook<\/h2>\n\n\n\n<p><code>process_record<\/code> trigger&nbsp;when viewing record list from web portal. Typically you should avoid using that logic hook for any serious business logic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Fixing the issue<\/h2>\n\n\n\n<p>If you find logic are not triggered, set logger level &nbsp;to &#8220;debug&#8221; option, trigger REST API and examine sugarcrm.log file. Find warning and error in the log. Common issues are using depreciated API, which execute with portal but does not execute with REST API. In this case, deprecated depreciated usage case to newer format.<\/p>\n\n\n\n<p>Another common issue is some filter function that check additional parameter are not appear when calling REST API.<\/p>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Logic Hook framework allows us to&nbsp;execute custom code on system&nbsp;events such as when creating, editing, and deleting records. A logic hook is defined in a file as PHP function which execute when an event is triggered. For more detail about SuiteCRM logic hook, see&nbsp;here. It is important to note that there are various ways [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[63,34,12,13],"class_list":["post-276","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-logic-hook","tag-rest-api","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM\" \/>\n<meta property=\"og:description\" content=\"The Logic Hook framework allows us to&nbsp;execute custom code on system&nbsp;events such as when creating, editing, and deleting records. A logic hook is defined in a file as PHP function which execute when an event is triggered. For more detail about SuiteCRM logic hook, see&nbsp;here. It is important to note that there are various ways [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-27T18:17:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:21:15+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/\",\"name\":\"Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2020-04-27T18:17:02+00:00\",\"dateModified\":\"2020-09-08T09:21:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Executing Logic Hook in SuiteCRM\/SugarCRM REST API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/","og_locale":"en_US","og_type":"article","og_title":"Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM","og_description":"The Logic Hook framework allows us to&nbsp;execute custom code on system&nbsp;events such as when creating, editing, and deleting records. A logic hook is defined in a file as PHP function which execute when an event is triggered. For more detail about SuiteCRM logic hook, see&nbsp;here. It is important to note that there are various ways [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/","og_site_name":"TechCRM","article_published_time":"2020-04-27T18:17:02+00:00","article_modified_time":"2020-09-08T09:21:15+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/","url":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/","name":"Executing Logic Hook in SuiteCRM\/SugarCRM REST API - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2020-04-27T18:17:02+00:00","dateModified":"2020-09-08T09:21:15+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/executing-logic-hook-in-suitecrm-sugarcrm-rest-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"Executing Logic Hook in SuiteCRM\/SugarCRM REST API"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=276"}],"version-history":[{"count":2,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/276\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/276\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}