How to replace value in add data row or array

Is it possible to replace a string in add data row.

My scenario is to pass value as arguments into add data row, but it is not accepting null or empty values.
So i need to replace the empty value to “-”


You can use StringVar.Replace("","-")

But i need to check for bulk columns (like 15 columns). I cant check each column

For that you need to give individually. I think there is no other way.

If it’s an array, you can make a loop and do it.

is there any option to replace the in array

Use For Each Activity and Replace with existing variable.

If your ArrayRow is of like this with variables holding values in it
{variable1.ToString, variable2.ToString,variable3.ToString}

Then mention like this in ArrayRow property

{IF(string.IsNullOrEmpty(variable1.ToString),”-“, variable1.ToString).ToString,
IF(string.IsNullOrEmpty(variable2.ToString),”-“, variable2.ToString).ToString,
IF(string.IsNullOrEmpty(variable3.ToString),”-“, variable3.ToString).ToString}

Cheers @Rachel7

You can use For Each Activity before adding that row
so in for each
If item.tostring.trim=“” or string.IsNullOrEmpty(item.tostring)

Hi @Rachel7

If you want to replace empty string in an array the below code will help you.

variable1 = variable1.Select(Function(x) x.Replace(" ", “-”)).ToArray()



Create a array with all the variables first. This is similar to the way you specify the valuea as a array row in add data row activity… use an assign activity and specify the array like

Array = {variable1, variable2… }

Now use a for each activity to loop through the array items

Inside the loop, add another assign activity and replace the item if it has nulls…

Item= IF(string.IsNullOrEmpty(item.ToString),”-“, item.ToString).ToString

@aanandsanraj, Thanks for this. it helped me to use for a similar thing in an optimized way.

1 Like