cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kchakor
Advocate I
Advocate I

array length

Hi ,

 

I need to verify if the array length is greater than 0 . Itry using : @greater(length(body('Get_records_sqlTable')?['value']), 0)

 

but the condition is alway true , even the outputs form my get_records is [] .

 

 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
v-micsh-msft
Community Support
Community Support

Hi @kchakor,

 

Could we take use of the empty fucntion instead of the length?

For checking if the array is empty, we could using the following formula:

@empty(body('Get_rows')?['value'])

Which would return true if object, array, or string is empty (for array, means no elements, 0 length).

For the formula you used here, try to convert the 0 use the int function:

@greater(length(body('Get_rows')?['value']),int('0'))

See if that would help.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-micsh-msft
Community Support
Community Support

Hi @kchakor,

 

Could we take use of the empty fucntion instead of the length?

For checking if the array is empty, we could using the following formula:

@empty(body('Get_rows')?['value'])

Which would return true if object, array, or string is empty (for array, means no elements, 0 length).

For the formula you used here, try to convert the 0 use the int function:

@greater(length(body('Get_rows')?['value']),int('0'))

See if that would help.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

it's work fine.

Thank you 

Hi @kchakor,

 

If convenient, would you please accept the workable posts as the solution?

So that others would find it more easily.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I have a similiar problem where I am building arrays in a for each and only want to create files or tables out of them if they are not empty.  When using the function within a condition:

 

@not(equals(empty(variables('check')), TRUE))  or even @not(equals(empty(variables('check')), bool(1))) or even the length and greater than int(o) , because int('o') throws an expression error for me when trying to save, I still get inconsistent results.

 

It will not producce tables for arrays that have content, and it creates tables for empty arrays - it's just inconsistent in how it evaluates it.  What am I doing wrong here?

Hi @v-micsh-msft 

By any chance can we get current row/line number ..?

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (100,880)