AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.02.2020, 15:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,626 / 848 (80) +++++++
Регистрация: 28.10.2006
crmtipoftheday: Tip #1322: Incorrect increment and decrement in Power Automate
Источник: https://crmtipoftheday.com/1322/inco...ower-automate/
==============

&tl;dr

When using Increment variable or Decrement variable actions, use coalesce function in the parameter to avoid unexpected results.

Explanation

It was a dark and stormy night. The tax was calculated in a Power Automate flow by looping through the array of applicable records and incrementing a total variable by the tax field value. The client threw a book at me and said that total tax is off by a few dollars. True story. (Except the throw and the book, the storm was real).

It’s not uncommon in Common Data Service (lol) to imply that when a decimal or money field contains null it’s equivalent to 0. For example, null tax means no tax or zero tax. The fun begins when you try to calculate total over an array of records.

What’s the result of this flow?

6? 7? 8? 9?We wouldn’t be here if it was 6, right? The answer is 8. Increment variable action implies the value of 1 for the Increment By parameter is not provided (value is null).

The fix is easy – use coalesce function.

coalesce(items('Apply_to_each'),0)And the result is now 6 which is about as much as Facebook pays in tax in a year. The above applies to Decrement variable action as well. Duh…




Источник: https://crmtipoftheday.com/1322/inco...ower-automate/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:04.