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

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Evaluating number of r...
Power Automate
Answered

Evaluating number of records returned by salesforce get records element

(0) ShareShare
ReportReport
Posted on by 25

i've spent a few long hours trying to evaluate whether the number of records returned by a salesforce get records element is equal to 1, but the basic question is how to evaluate the number of records found.

 

i have a get records element, followed by a condition set to evaluate if an expression is equal to 1.  the yes/no path both send an email for testing purposes.

 

i tried the following

 

expression : length(body('Get_records'))

error : The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'.

 

so i converted the body to an array.

 

expression : length(createArray(body('Get_records')))

2 records are found, but it still goes down the 'true' path, meaning it found that the expression == 1.

 

i have tried both of these with body('Get_records')?['value']) as well, and the results are the same.

 

here is the output from the get records element where 2 records are found

 

 

 

 

 

{
 "@odata.context": "https://flow-apim-msmanaged-na-eastus2-01.azure-apim.net/apim/salesforce/shared-salesforce-b1fc4548-a672-411f-be17-317aff51b9c4/$metadata#datasets('default')/tables('OpportunityPayment__c')/items",
 "value": [
 {
 "@odata.etag": "",
 "ItemInternalId": "9e7908fc-7eb9-40c3-b24e-6b6b224f05be",
 "CreatedById": "00540000001CkxPAAS",
 "CreatedDate": "2020-07-21T17:51:12Z",
 "CurrencyIsoCode": "EUR",
 "Id": "a0E0R000002oi5TUAQ",
 "IsDeleted": false,
 "LastActivityDate": null,
 "LastModifiedById": "00540000001CkxPAAS",
 "LastModifiedDate": "2020-07-21T20:49:17Z",
 "LastReferencedDate": "2020-07-21T20:49:19Z",
 "LastViewedDate": "2020-07-21T20:49:19Z",
 "Name": "P-120713",
 "SystemModstamp": "2020-07-21T20:49:17Z",
 "Account_Credited__c": "Stripe",
 "Amount_Received__c": 12345,
 "Amount_USD__c": 12345,
 "Broker__c": null,
 "Check_Date__c": null,
 "Deposit_Date__c": null,
 "Exchange_Rate__c": 1,
 "Fees__c": null,
 "GA_claimed_date__c": null,
 "Gift_Aid_signed__c": false,
 "ID__c": null,
 "Name_Details__c": null,
 "Number_of_Shares__c": null,
 "Old_Amount_Received__c": null,
 "Other_Information__c": "sub_HgnC03jnVVv9uJ",
 "Payment_Currency__c": "EUR",
 "Payment_Due_Date__c": "2020-07-21",
 "Payment_Received_Date__c": "2020-07-21",
 "Payment_Type__c": "Credit Card",
 "Payment_for__c": "0060R00000EAaV8QAL",
 "Sale_Date__c": null,
 "Selling_Price_Market_Value__c": null,
 "Subscription_Id__c": "sub_HgnC03jnVVv9uJ"
 },
 {
 "@odata.etag": "",
 "ItemInternalId": "a62276be-ef2b-4e3d-be86-509f9f6978cb",
 "CreatedById": "00540000001CkxPAAS",
 "CreatedDate": "2020-07-21T20:49:25Z",
 "CurrencyIsoCode": "EUR",
 "Id": "a0E0R000002okNfUAI",
 "IsDeleted": false,
 "LastActivityDate": null,
 "LastModifiedById": "00540000001CkxPAAS",
 "LastModifiedDate": "2020-07-21T20:49:25Z",
 "LastReferencedDate": "2020-07-21T20:49:27Z",
 "LastViewedDate": "2020-07-21T20:49:27Z",
 "Name": "P-120714",
 "SystemModstamp": "2020-07-21T20:49:25Z",
 "Account_Credited__c": "Stripe",
 "Amount_Received__c": 12345,
 "Amount_USD__c": 12345,
 "Broker__c": null,
 "Check_Date__c": null,
 "Deposit_Date__c": null,
 "Exchange_Rate__c": 1,
 "Fees__c": null,
 "GA_claimed_date__c": null,
 "Gift_Aid_signed__c": false,
 "ID__c": null,
 "Name_Details__c": null,
 "Number_of_Shares__c": null,
 "Old_Amount_Received__c": null,
 "Other_Information__c": "sub_HgnC03jnVVv9uJ",
 "Payment_Currency__c": "EUR",
 "Payment_Due_Date__c": "2020-07-22",
 "Payment_Received_Date__c": "2020-07-22",
 "Payment_Type__c": "Credit Card",
 "Payment_for__c": "0060R00000EAaV8QAL",
 "Sale_Date__c": null,
 "Selling_Price_Market_Value__c": null,
 "Subscription_Id__c": "sub_HgnC03jnVVv9uJ"
 }
 ]
}

 

 

 

 

and here is a screenshot of the flow

 

Screenshot from 2020-07-21 17-07-37.png

 

so...any suggestions on how to determine the number of records returned (or simply, if any records are returned?)

Categories:
I have the same question (0)
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @GKS 

     

    Have you tried the expression: 

     

    length(body('Get_records')?['value'])

     

    and compared that with 1? Can you check if there are no trailing whitespaces after '1' in the condition? 

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • GKS Profile Picture
    25 on at

    Thanks @yashag2255 

     

    that was it.  the createArray was wrapping the whole response in an outer array, and that is what was equal to 1.

    createarray is not required as the value is an array.  

     

    cheers

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…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
trice602 Profile Picture

trice602 237 Super User 2026 Season 1

#2
David_MA Profile Picture

David_MA 176 Super User 2026 Season 1

#3
Power Platform 1919 Profile Picture

Power Platform 1919 96 Super User 2026 Season 1

Last 30 days Overall leaderboard