{"id":36226,"date":"2023-10-16T15:20:41","date_gmt":"2023-10-16T09:50:41","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=36226"},"modified":"2023-10-16T15:49:16","modified_gmt":"2023-10-16T10:19:16","slug":"pro-tip-how-to-use-updateif-in-canvas-app","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2023\/10\/pro-tip-how-to-use-updateif-in-canvas-app\/","title":{"rendered":"Pro Tip &#8211; How to use UpdateIf() in Canvas App"},"content":{"rendered":"<p>Let us explore the use and functionalities of the <strong>UpdateIf()<\/strong> Function using some simple examples.<\/p>\n<h2><strong>Requirements<\/strong><\/h2>\n<p>Suppose, we have created a data table in our canvas app, where we have some records. We have created an option set field on the Account form with the name \u2018Preference\u2019 where we have different options i.e. Basic, Premium, etc. We need to set <strong>Premium<\/strong> as the value of the preference field for the records that have annual revenue of more than $5,000,000. The value for preference should be set for all records present in the table at the click of a button.<\/p>\n<p>To achieve the above customer requirement, we have created a Canvas App and tried to implement it using the UpdateIf() Function.<\/p>\n<h2><strong>UpdateIf Function<\/strong><\/h2>\n<p>To change one or more values in one or more records that match one or more conditions, use the UpdateIf function. Any formula that returns a true or false result can be used as the condition, and it can explicitly refer to specific columns in the data source. Each record&#8217;s condition is evaluated by the function which updates any records for which the result is true. UpdateIf, return a table using the changed data source.<\/p>\n<h2><strong>Syntax<\/strong><\/h2>\n<p><strong>UpdateIf<\/strong>( DataSource, Condition1, ChangeRecord1 [, Condition2, ChangeRecord2, &#8230;.])<\/p>\n<ul>\n<li><strong>DataSource <\/strong>\u2013 Required. The source of the record or records to be modified is required.<\/li>\n<li><strong>Condition(s)<\/strong> \u2013 Required. A formula that, when applied to the record or records you want to change, returns true. The formula can use the Data Source\u2019s column names.<\/li>\n<li><strong>ChangeRecord(s)<\/strong> &#8211; Required. A change record of new property values to be applied to DataSource records that meet the condition is created for each corresponding condition. The property values of the existing record can be used in the property formulas if you provide the record inline using curly braces.<\/li>\n<\/ul>\n<p>To achieve this requirement, we have added one button in the canvas app and entered the following code in its OnSelect property:<\/p>\n<p><strong>UpdateIf(Accounts, &#8216;Annual Revenue&#8217; &gt;= 5000000, {Preference:&#8217;Preference(Accounts)&#8217;.Premium})<\/strong><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-36227\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App.jpeg\" alt=\"Canvas App\" width=\"1907\" height=\"889\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App.jpeg 1907w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App-300x140.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App-1024x477.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App-768x358.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App-1536x716.jpeg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/1Canvas-App-660x308.jpeg 660w\" sizes=\"(max-width: 1907px) 100vw, 1907px\" \/><\/p>\n<p>After saving the above changes we must click the update button for the above-mentioned formula to execute, then the preference field will be set as Premium for all the records present in the data table that have an Annual Revenue of more than $5,000,000.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-36228\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App.jpeg\" alt=\"Canvas App\" width=\"1507\" height=\"693\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App.jpeg 1507w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App-300x138.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App-1024x471.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App-768x353.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/2Canvas-App-660x304.jpeg 660w\" sizes=\"(max-width: 1507px) 100vw, 1507px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>The <strong>UpdateIf()<\/strong> function provides new options for the PowerApps formula in Dynamics 365. Users can easily update the record\u2019s data based on the desired conditions by executing a simple powerFX formula instead of writing a script or doing some lengthy workaround to achieve the requirement. This opens new options for the canvas apps since it relies mostly on the powerFX formula.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/services\/\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-36229\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/10\/Canvas-App.gif\" alt=\"Canvas App\" width=\"880\" height=\"220\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let us explore the use and functionalities of the UpdateIf() Function using some simple examples. Requirements Suppose, we have created a data table in our canvas app, where we have some records. We have created an option set field on the Account form with the name \u2018Preference\u2019 where we have different options i.e. Basic, Premium,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2023\/10\/pro-tip-how-to-use-updateif-in-canvas-app\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1954],"tags":[1988],"class_list":["post-36226","post","type-post","status-publish","format-standard","hentry","category-canvas-apps","tag-canvas-apps"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/36226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=36226"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/36226\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=36226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=36226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=36226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}