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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.03.2024, 15:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
crmtipoftheday: Tip #1446: Empty array in Power Automate
Источник: https://crmtipoftheday.com/1446/empt...power-automate
==============

To create an empty array in a Power Automate formula, just use json('[]'). That’s it — there’s your entire tip.

But when might you need this? Let’s say you’re working with the same third-party service as I did the other day. The service returns an array of objects, and you need to loop through the returned objects. Now, if no objects are found, a well-designed service would typically return an empty array. But this one? It returns null. Bleugh. You could add an if action, but there’s a neater solution. Use the following formula in the ‘Apply to each’ action:

coalesce( outputs('Custom_Service')?['body/value'], json('[]') )
This approach uses the coalesce function to check the output from the custom service, and if it’s null, it falls back to an empty array, thanks to json('[]'). Empty array means the loop is simply not executed which is exactly what we wanted.

Cover Image by Andrew Martin from Pixabay.



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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crmtipoftheday: Tip #1444: New Power Automate UI unearths hidden property Blog bot Dynamics CRM: Blogs 0 01.03.2024 05:35
crmtipoftheday: Tip #1434: Can you count OR how to add index to array in Power Automate Blog bot Dynamics CRM: Blogs 0 05.04.2022 09:11
crminthefield: Dynamics 365 and Power Platform Monthly Update-September 2021 Blog bot Dynamics CRM: Blogs 0 11.09.2021 09:04
crminthefield: Dynamics 365 and Power Platform Monthly Update-August 2021 Blog bot Dynamics CRM: Blogs 0 12.08.2021 06:20
crminthefield: Dynamics 365 and Power Platform Monthly Update-July 2021 Blog bot Dynamics CRM: Blogs 0 14.07.2021 02:22

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 20:08.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.