Help with For Each and If practice (min & max) in Academy

I am working on Practice 1: For Each and If questions and I am not able to generate the correct max and min value for the practice. I’ve followed their solution steps and reviewed the downloaded file from the practice.

I am getting an error in the For Each activity where “Element” in the If condition is giving me error BC30389. and if i set “Element” as a variable, the workflow generates incorrect max and min values.

Below are the steps from UiPath Academy solution steps

  • Use a For Each activity to go through each item in the array: For Each Element in InitArray
  • Drag two If activities inside the body of the For Each:
  • Set the condition for the first If to “Element < MinValue” to compare the values in the array and identify the smallest. Inside the Then block, add an Assign activity to assign Element to MinValue.
  • Set the condition for the second If to “Element > MaxValue” to compare the values in the array and identify the largest. Inside the Then block add an Assign activity to assign Element to MaxValue.

Can someone advise how can I fix the workflow to generate the correct max and min value?

@amypochacco

Welcome to the community

Can you show some screenshot please

Initially are you assigning minvaluw with the forst value or so? Or else minvalue as it is integer will take 0 as the value

Is element the for each variable? Generally it would be currentelement or so..can you click ctrl+space inside for each in the if condition and check what variable is coming and if you have given the correct one

Cheers

I found the issue. I have to set Item Name in the For Each Properties and able to resolve.

1 Like

Hi @amypochacco
The key issue you’re running into — BC30389 — typically points to a data type mismatch or an undeclared/ambiguous variable.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.