cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ML2020
New Member

Folder name date suffix from JS - Illegal characters in path

Hello,

 

I would like to create the PAD flow, which takes current DateTime, converts it to string in format DDMMYYYY_HHMMSS and creates the folder and file which will be using this string as a suffix eg. folder with name "Data created on 03022021_123821" should be created.

PAD contains action for running JS (Run JavaScript), so I used this action to create this suffix. Code below:

 

var curDateTime = new Date();
var dateStringArray = [];

dateStringArray.push((curDateTime.getDate()<10?"0":"")+curDateTime.getDate());
dateStringArray.push((curDateTime.getMonth()+1<10?"0":"")+(curDateTime.getMonth()+1));
dateStringArray.push("" + curDateTime.getFullYear());
dateStringArray.push("_");
dateStringArray.push((curDateTime.getHours()<10?"0":"")+curDateTime.getHours());
dateStringArray.push((curDateTime.getMinutes()<10?"0":"")+curDateTime.getMinutes());
dateStringArray.push((curDateTime.getSeconds()<10?"0":"")+curDateTime.getSeconds());

var dateString = dateStringArray.join('');

WScript.echo(dateString);

 

 

This JS provides correct dateString and is exported from action to JavascriptOutput variable. However when this output is used in actions to create/rename file/folder, an error is displayed. I tried to remove the time and leave just date part of the suffix, but the result is the same:

 

Robin.Core.ActionException: Can't create folder Data created on 03022021
 into C:\Users\powerplatform003\Documents\DUMMY_FI Team. ---> System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
   at System.IO.Path.Combine(String path1, String path2)
   at Robin.Modules.Folder.Actions.FolderActions.CreateFolder(Variant newFolderPath, Variant newFolderName, Variant& newFolder)
   --- End of inner exception stack trace ---
   at Robin.Modules.Folder.Actions.CreateFolder.Execute(ActionContext context)
   at Robin.Runtime.Engine.ActionRunner.RunAction(String action, Dictionary`2 inputArguments, Dictionary`2 outputArguments, IActionStatement statement)

 

Now, when we use 03022021 suffix directly (not as a result from JavaScript), the above error is not happening.

Did anybody else have simillar situation?

 

Regards,

ML

3 REPLIES 3
miketran13
Solution Specialist
Solution Specialist

Hi,

 

Can you take more screenshots of your detail actions on PAD? 

 

And by the way, why do you need to have the JS script to just convert and format the datetime. You can do that with these simple actions in PAD. 

 

datetime.png

 

Thanks and hope it can help you. 

Mike

---------------------------------

Did I answer your question? Please consider to Mark my post as a solution! to guide others

kelway
Helper II
Helper II

You probably figured it out by now, but the issue is that WScript.echo outputs a CRLF at the end of the variable.

THANK YOU!  This is the proper answer.  Had a very similar issue running Shell script which was returning a file path that I was using in the 'Read text from file' command that would result in the 'illegal character in path' error.  Simply trimmed the variable and we are in business.  Thank you!

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,367)