How to remove the '\n' from the output of Powershell on Workflow's activity designer?

Bird1
Mega Sage

Hello,

 

I need 1 help. I do have Powershell Script to create Active Directory account, so I create 'activity designer' and embed the Powershell script there. The output is set as 'Direct'. 

 

So far, the Powershell Script works well, it could create Active Directory account but I faced the Output in that activity designer, it will always add '\n' as prefix so like below captured screen, the script could create Active Directory account: 'mit' but the Output will show as '\nmit'. 

 

I will really need this output to be the input of the next activity, so it will be failed because of '\n' prefix.

 

I am not sure is there any way to

A) remove the '\n' either from the output 

B) if the choice A) to remove '\n' from the output of current activity is not possible, can we remove '\n' from the input of the next activity designer instead?

 

PS: I have tried the same Powershell Script adding to action designer on the Flow Designer, there's no problem, it could return output as 'mit' without '\n' prefix, so the problem is only from Activity Designer's workflow

 

 

 

Bird1_1-1701830508437.png

 

 

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Bird1 

Coming to the option B,

You can have a Script Activity and use the replace method on the output string. Like YourVariable.replace("\\n", ""); and store it into a scratch pad variable for use in other work flow activities.

 

If the above one didn't work, try just \n instead of \\n.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

View solution in original post

11 REPLIES 11

AnveshKumar M
Tera Sage
Tera Sage

Hi @Bird1 

Coming to the option B,

You can have a Script Activity and use the replace method on the output string. Like YourVariable.replace("\\n", ""); and store it into a scratch pad variable for use in other work flow activities.

 

If the above one didn't work, try just \n instead of \\n.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

Hi AvneshKumar,

 

Is it possible if I choose option A to add output post processing script? I tried below one but still get the '\n' as prefix.

 

Bird1_0-1701845396808.png

 

@Bird1 Have you tried the "\\n".

activityOutput.Output = activityOutput.Output.replaceAll("\\n", "");

Thanks,
Anvesh

I've tried to update to activityOutput.Output = activityOutput.Output.replaceAll("\\n",""); but still get '\n' prefix.

 

Bird1_0-1701853032799.png

 

Bird1_1-1701853060476.png

 

 

Bird1_2-1701853114269.png