{"id":769,"date":"2022-01-12T17:22:25","date_gmt":"2022-01-12T17:22:25","guid":{"rendered":"https:\/\/logicbuilder.integroscrm.com\/help\/?page_id=769"},"modified":"2022-08-03T17:27:01","modified_gmt":"2022-08-03T17:27:01","slug":"on-data-change","status":"publish","type":"page","link":"https:\/\/logicbuilder.integroscrm.com\/help\/on-data-change\/","title":{"rendered":"On Data Change"},"content":{"rendered":"\n<p><a name=\"abstract\"><\/a>Fires the flowchart logic when the record is changed. This is the Start Element of the flowchart.<\/p>\n\n\n\n<p>Record is changed means that there was Save event of the entity &#8211; by a user through the interface, via API, or by other flowchart or custom logic_hook.<\/p>\n\n\n\n<p>It doesn&#8217;t fire the flowchart when:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>the change was made through the database directly<\/li><li>when one record is linked to another one via a many-to-many relationship type (use <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/on-link-change\/\">On Link Change<\/a> for this).<\/li><\/ul>\n\n\n\n<p><strong>inputs:<\/strong><\/p>\n\n\n\n<p><span style=\"color:#9ed267;\">module<\/span> &#8211; select directly in the operator the module which record change is in focus<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><span style=\"color:#9ed267;\">event type<\/span> &#8211; select when logic must be fired:<\/p>\n\n\n\n<p><em>before_save<\/em>&nbsp;&#8211; &nbsp;executes before a record is saved (note that these changes aren&#8217;t seen through the interface directly on the View prior to the record being saved. Before save means that the logic is executed after the save event from the client-side but prior to actual save into database)<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>For Before Save logic please consider the following:<\/p>\n<ul>\n<li>some fields values may not be set (e.g. the case_number field for the Cases module) as this business logic has yet to be executed.<\/li>\n<li>do not use <span style=\"color:#ec8f45;\">Save Entity<\/span> for the Entity which is selected in On Data Change, as this entity will be saved by Sugar<\/li>\n<\/ul>\n<\/div>\n\n\n<p><em>after save<\/em>&nbsp;&#8211; executes after a record is saved<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Required: yes<\/li><\/ul>\n\n\n\n<p><strong>outputs:<\/strong><\/p>\n\n\n\n<p><span style=\"color:#ef6950;\">entity<\/span> &#8211; a record where a change event has occurred. Here entity is in the state as it was saved by user\/API\/another flowchart or whatever executes the current flowchart. Commonly followed by <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/get-entity-attributes\/\">Get Entity Attributes<\/a>.<\/p>\n\n\n\n<p><span style=\"color:#ef6950;\">previous values<\/span> &#8211; a record in a state of how it was before most recent changes, which fired this flowchart. Commonly followed by <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/get-entity-attributes\/\">Get Entity Attributes<\/a> and is compared with output from <span style=\"color:#ef6950;\">entity<\/span> to check whether particular fields values were changed.<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>Apparently in&nbsp;<em>after save<\/em>&nbsp;logic the related fields that are part of the one-to-many relationship are always (each save event)&nbsp;empty in previous values. To get previous record use <a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/on-link-change\/\">On Link Change<\/a>.<\/p>\n<\/div>\n\n\n<p><span style=\"color:#deb7ca;\">is new<\/span> &#8211; contains&nbsp;<em>true&nbsp;<\/em>when the record is new or&nbsp;<em>false&nbsp;<\/em>when this is an update of the existing one<\/p>\n\n\n\n<p><span style=\"color:#9ed267;\">changed fields<\/span> &#8211; a collection of fields system names that were changed. Works only for&nbsp;<em>after_save<\/em>&nbsp;logic.<\/p>\n\n\n<div style=\"background-color: #ddeaff; border-left: 6px solid #0072b3; padding: 12px;\">\n<p>Note that each save event (even when the record was just opened and clicked save) contains date modified, modified_by_name.<\/p>\n<p><a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-93-1ac8e7a3253e45d2bf277be43544bad6.png\" rel=\"prettyPhoto\"><img decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-93-1ac8e7a3253e45d2bf277be43544bad6.png\" alt=\"\" class=\"wp-image-378\"><\/a><\/p>\n<p>Use this output carefully for new records, as in fields there are data about related objects which contain&nbsp;a huge amount of data to be output. When using for new records, specify exact fields that are in focus rather than output all.<\/p>\n<\/div>\n<p><a href=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-93-bef0356536f14828b41753bdb81d062c.png\" rel=\"prettyPhoto\"><img decoding=\"async\" src=\"https:\/\/logicbuilder.integroscrm.com\/help\/wp-content\/uploads\/2021\/12\/img-93-bef0356536f14828b41753bdb81d062c-1024x284.png\" alt=\"\" class=\"wp-image-378\"><\/a><\/p><div style=\"text-align:left\" class=\"yasr-auto-insert-visitor\"><!--Yasr Visitor Votes Shortcode--><div id='yasr_visitor_votes_769' class='yasr-visitor-votes'><div class=\"yasr-custom-text-vv-before yasr-custom-text-vv-before-769\">Click to rate this post!<\/div><div id='yasr-vv-second-row-container-806e680390a3b' \n                                        class='yasr-vv-second-row-container'><div id='yasr-visitor-votes-rater-806e680390a3b'\n                                      class='yasr-rater-stars-vv'\n                                      data-rater-postid='769' \n                                      data-rating='0'\n                                      data-rater-starsize='24'\n                                      data-rater-readonly='false'\n                                      data-rater-nonce='fa81b01ba5' \n                                      data-issingular='false'\n                                    ><\/div><div class=\"yasr-vv-stats-text-container\" id=\"yasr-vv-stats-text-container-806e680390a3b\"><svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" width=\"20\" height=\"20\" \n                               class=\"yasr-dashicons-visitor-stats\"\n                               data-postid=\"769\" \n                               id=\"yasr-stats-dashicon-806e680390a3b\">\n                            <path d=\"M18 18v-16h-4v16h4zM12 18v-11h-4v11h4zM6 18v-8h-4v8h4z\"><\/path>\n                          <\/svg><span id=\"yasr-vv-text-container-806e680390a3b\" class=\"yasr-vv-text-container\">[Total: <span id=\"yasr-vv-votes-number-container-806e680390a3b\">0<\/span>  Average: <span id=\"yasr-vv-average-container-806e680390a3b\">0<\/span>]<\/span><\/div><div id='yasr-vv-loader-806e680390a3b' class='yasr-vv-container-loader'><\/div><\/div><div id='yasr-vv-bottom-container-806e680390a3b' class='yasr-vv-bottom-container'><\/div><\/div><!--End Yasr Visitor Votes Shortcode--><\/div>","protected":false},"excerpt":{"rendered":"<p>Fires the flowchart logic when the record is changed. This is the Start Element of the flowchart. Record is changed means that there was Save event of the entity &#8211; by a user through the interface, via API, or by other flowchart or custom logic_hook. It doesn&#8217;t fire the flowchart when: the change was made &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/logicbuilder.integroscrm.com\/help\/on-data-change\/\"> <span class=\"screen-reader-text\">On Data Change<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","footnotes":""},"tags":[],"class_list":["post-769","page","type-page","status-publish","hentry"],"yasr_visitor_votes":{"number_of_votes":0,"sum_votes":0,"stars_attributes":{"read_only":false,"span_bottom":false}},"_links":{"self":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/comments?post=769"}],"version-history":[{"count":8,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/769\/revisions"}],"predecessor-version":[{"id":2066,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/pages\/769\/revisions\/2066"}],"wp:attachment":[{"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/media?parent=769"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/logicbuilder.integroscrm.com\/help\/wp-json\/wp\/v2\/tags?post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}