web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Need help loop trough ...
Power Automate
Unanswered

Need help loop trough all records

(0) ShareShare
ReportReport
Posted on by 817

Hi all. 

 

i tries searching for the answer but I wasn't able to find any solution, so my last action is to ask here.

I have a workflow which when a email address is received from Power Virtual Agent, it will go in Dynamics CRM, will search for an existing account with this email address, and if available i want to return all subscriptions.

 

I have a custom entity called subscriptions, that contains a certain product (OOB entity in CRM), contains start and expiration date, and account (lookup to Account entity).

So if a user ask the bot when my subscription expires, the bot will ask the user for an email address, power automate will search for an account with this email address, and then will loop trough all subscriptions of the account and will say something like. "i see the following subscriptions are available for the Account (account name field) which expires on Expiration Date filed

 

So basically here we have two entities involved

Account and Subscription.

From Account i need the Account Name filed which i can get with the List records step where i'm filtering the result by email address input from the user.

From subscription i need only the expiration date filed.

This is the WF how it looks like so far.

Radoslavov_0-1607501408390.png

here I'm searching for subscriptions where account is the same as the previous result

Radoslavov_1-1607501454085.png

 

And here is basically where i'm stuck in getting the details for each result (each subscription)

I'm sharing also a subscription entity solution for dynamics crm in case someone want to test it.

https://crm632903-my.sharepoint.com/:u:/g/personal/admin_crm632903_onmicrosoft_com/Ea_bVHucYBVLqfZHCzYJwbABiKFX56c_xu6OM_3pBfwJLw?e=RdPQlK

So if the account have 3 subscriptions i should be able to get each of these 3 subscription's expiration dates values and pass it over to the bot as Output results.

 

Hope manage to explain the scenario well.

Let me know if you have more clarification.

Regards

Kiril

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Need help loop trough all records

    Hello @Radoslavov 

    After getting the account record, you should:

    1) Check if there's at least one element (condition).

    2) Get Account value of the first element.

    3) Get the subscriptions for that account.

    accounts.png

     

    Hope it helps!

    Ferran

     

  • Radoslavov Profile Picture
    817 on at
    Re: Need help loop trough all records

    Hi @fchopo ,

     

    I've added the extra steps however now I'm trying to add as outputs the subscription properties such as Subscription number and Expiration date, which i can see from the list of options but still get the error message: The output you selected is inside a collection and needs to be looped over to be accessed. This action cannot be inside a foreach.

    Radoslavov_0-1607509515687.png

    Any suggestions how to add this properties?

     

    Regards

    Kiril

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Need help loop trough all records

    Hello @Radoslavov 

    I would add the results to a string variable, and then return it to PVA (after the apply to each):

    subscriptions.png

     

    Hope it helps!

    Ferran

  • Radoslavov Profile Picture
    817 on at
    Re: Need help loop trough all records

    Great, i think that I'm only missing something as i'm unable to select anything for name as on your picture. I guess there should be a step somewhere with additional actions.

    Radoslavov_0-1607587357671.png

    Radoslavov_1-1607587557236.png

    Apologies it is my first time using array functions in flow. Once i understand how it works for sure will get better.

     

    Regards

    Kiril

     

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Need help loop trough all records

    Hello @Radoslavov 

    Sorry, I forgot to mention I used an "Initialize Variable" action at the beginning of the flow:

    subs2.png

     

    Regards,

    Ferran

  • Radoslavov Profile Picture
    817 on at
    Re: Need help loop trough all records

    Still not working

    i did the following changes

    Radoslavov_0-1607596773274.png

    If(greater(length(outputs('Get_Account')?['body/value']),0), true, false)

    Radoslavov_1-1607596815149.png

    Radoslavov_4-1607596995856.png

     

    Radoslavov_5-1607597034435.png

    Radoslavov_6-1607597063498.png

    `but my flow fails

    Radoslavov_7-1607597106467.pngRadoslavov_8-1607597149702.png

    Any idea what might have gone wrong in the flow?

    regards

    Kiril

     

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Need help loop trough all records

    Hello @Radoslavov 

    In the "Get Subscription Details" action you are using a filter expression that is not allowed, since the crbc2_Account field is a binary one and could not be compared with a string value. Could you use the following filter?

    crbc2_account_value eq '...'

     

    Have a look at this thread about comparing guid values: Solved: Filter Query in List Records not working for Looku... - Power Platform Community (microsoft.com)

     

    Regards,

    Ferran

  • Radoslavov Profile Picture
    817 on at
    Re: Need help loop trough all records

    Nope,

     

    Could not find a property named 'crbc2_account_value' on type 'Microsoft.Dynamics.CRM.crbc2_subscriptions'.

    Radoslavov_0-1607604471857.png

    I dont know what else to try.

     

    regards

    Kiril

  • Radoslavov Profile Picture
    817 on at
    Re: Need help loop trough all records

    perhaps there is another way to build the flow to achieve the same result?

  • fchopo Profile Picture
    8,003 Moderator on at
    Re: Need help loop trough all records

    Hello @Radoslavov 

    We are getting closer. If we want to know the internal name of the crbc2_account column, you should excute the flow, or at least the action, and inspect the output. Could you please create another flow and add the Get Subscriptions action and see the output results? There we will be able to see the column names.

    Regards,

    Ferran

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard