cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GKS
Frequent Visitor

Evaluating number of records returned by salesforce get records element

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?)

1 ACCEPTED SOLUTION

Accepted Solutions
yashag2255
Dual Super User II
Dual Super User II

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!

View solution in original post

2 REPLIES 2
yashag2255
Dual Super User II
Dual Super User II

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!

View solution in original post

GKS
Frequent Visitor

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

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,551)