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  Bro, 

 

May need your help if go to option B, I am not much familiar with workflow script (I started from Flow Designer and rarely use Workflow).

 

I am not sure that how to get the output data from the New AD User - New Naming Convention (activity.output.output), and write script to remove '\n' and get a new Output for next activity designer use? 

@AnveshKumar M  Bro, 

 

Finally, I can achieved it. You're right. We need to use the workflow scratchpad to store the variable and run the script to remove the '\n'. 

 

I am delayed to reply due to I am not familiar with workflow much (I started from Flow Designer). I will mark accept solution for you. 

 

Thanks.

@Bird1 I'm glad that it helped you 👍

Thanks,
Anvesh

Tai Vu
Kilo Patron
Kilo Patron

Hi @Bird1 

In your custom workflow activity, you can include a step named "Post Processing." Within this step, you can add an Output process script where you use the replaceAll function to remove the character "\n."

 

Cheers,

Tai Vu

Could you please advise?

 

This is my output variable.

Bird1_1-1701836730403.png

 

I've tried to add the post processing script like this

 

Bird1_2-1701836766234.png

 

When I tried to run testing, it still shows \n prefix.

Bird1_3-1701836828600.png