Replace - Value cannot be null (Library only)

I’m trying to use the Replace activity to clean some text and remove any funny characters. It should replace anything matched by “[^a-zA-Z0-9\r\n\t\f\v !”“#$%&'()*+,-./:;<=>?@[\]^_`{|}~]” with an empty string “”

UiPath-Replace-CleanText

It works fine when I call it directly, but not in a Library Process.
When I publish it as part of an Activity and then try to use the Library Activity in a regular process flow, it gives me the following error:

Value cannot be null.
Parameter name: replacement

Hi @cmora

I know that is not the best solution, but inside your library, just before the replace activity, you can add an If Activity checking if the input replacement string is null or empty, and if it is true, use and assign activity an set to = “” again.

Best of luck,

Andres

@cmora Try Using String.Empty instead of “” and Check

2 Likes

Try using IsNullOrEmpty(String str) before calling Replace Activity

@supermanPunch Thank you, String.Empty worked. It’s still odd that it compiles differently in a Library then in a regular Process, but from now on I’ll use String.Empty instead of “” or vbNullString.

1 Like

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