Help required in replacing a value from a column based on a condition

Hi Everyone,

Need urgent help on below instance.

I have a datatable with 27 columns I want to check that in a column “Policy value” if value starts with “Windows” then replace old value with new value.

ex- Windows - abc - def
replaced value - WIndows – abc – def.

I need a Linq query approach for this.

Thanks in advance !

@ppr can you help here?

hi @Yoichi , can you help here ?

Thanks!

Hi,

Basically, the following code will work in InvokeCode activity.

dt.AsEnumerable.ToList.ForEach(Sub(row)
If row("Policy value").ToString.StartsWith("Windows") Then
    row("Policy value")="New value"
End If
End Sub
)

I couldn’t get your requirement regarding replacement. Can you elaborate?

Regards,

Hi @Yoichi,

This For Each solution I have tried but is a bit slow.

Requirement is, in a Datatable which has 27 columns there is a column named Check Description I want to check if the item starts with Windows I want to replace “-” value with a EN - Dash value in that row and output the final datatable.

Let me know if you got the requirement or i Can elaborate more.

Thanks!

HI,

Do you mean you already tried this using InvokeCode activity?

Regards,

Yes, Tried using invoke code activity.

Thanks!

Hi,

I think InvokeCode is one of the fastest ways in UiPath. It might be difficult to improve performance more.

dt.AsEnumerable.ToList.ForEach(Sub(row)
    If row("Policy value").ToString.StartsWith("Windows") Then
        row("Policy value")=row("Policy value").Replace("-","EN -")
    End If
End Sub
)

Regards,

Filter rows first and update the affected ones afterwards

Thankyou @ppr and @Yoichi for your solutions and suggestion !

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