Array variable double value

Hi I have this array, if I wanted to identify if something appeared, like “Ice” has done in this list and store it in a string variable how would I do this?

Hi @Karan_Chauhan

Iterate the array variable arrweak with for each loop activity.
Take a If condition and write like CurrentItem = “Ice” in then block take an assign activity create a string variable. In assign Variable1 = CurrentItem. Then it will store the Ice in the variable1.

Hope it helps!!

Hi @Karan_Chauhan

Use For each
Inside for each
If CurrentItem=“Ice”
Assign: Str_Var= CurrentItem

Hope it helps!!

yourArrayVar.Contains(“Ice”) will return true when an item with the value Ice is present in the list

1 Like

sorry I want it to be dynamic, Ice was just an example as it had happened there but it could either come up or be a different wording.

Hi @Karan_Chauhan

Use For each activity and inside for each use if condition and write the condition as Currentitem = “ice” and within if condition take assign activity and assign the current item to that variable.

Regards

Also if it appeared twice is what I meant

Also if it appeared twice is what I meant

whenever we write in an sample a hardcoded value we can also dynamize it by a variable.
YourVar.Contains(KeyWordVar)

We would more recommend to more detail specify the requirements

1 Like

Hi @Karan_Chauhan ,

U want to identify the “ice” in the array use

array.contains(“ice”)

it returns a boolean result(true/false)

and you want to get the “ice” word from the array use this expression :

arrayvar(array.indexof(arrayvar,“ice”)).ToString

thanks
priya

@Karan_Chauhan

If you add a break activity after the assign activity then the loop gets stopped if not the value will be re-assigned to that variable.

Hello @Karan_Chauhan

Use the below expression in the Assign activity :
Assign Value TestStr (Type array of String) = (from item in arrWeak where item.Equals(“Ice”) Select item).ToArray()

Regards,
Rohith

I don’t understand the point of getting the value from the array. You already know the value is Ice because you checked if Ice exists in the array.

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