Skip to Content
Technical Articles
Author's profile photo Chirihan CHERGUI

Best Practices for managing files in intelligent Robotic Process Automation Desktop Studio

Pre-requisites & Disclaimer

 

This blog is intended for Desktop Studio versions of SAP intelligent RPA.

This blog provides resources that helps you implement best practice for files management but it doesn’t replace the sap official documentation available here.

 

Introduction

 

For many processes that require managing files, you are brought to creating, storing, and modifying files and folders on the local machine.

In many cases, you will put in place specific instructions for the end-users to follow to help the RPA work.

This end-up becoming additional things for the end-users to think about….

Imagine business cases where the end-users need to replace their machines often, or when users delete by accident some folders or files intended for the bot usage: The bot will fail, and the process supervisor will need to spend time on unnecessary investigations. So why not embrace some best practices for File management.

 

Configuration File that works for different users and machines

A typical example would be that you need to place a file/folder locally. Asking end-users to create a folder manually for the bot is not very convenient. Also, it’s hard to find a conventional path name that would work for all users in your organization.

You can avoid this by making your bot create these folders by default. Hence, if the bot can’t find the required folder on the machine, it will create it. You can make it even more convenient by adding a condition for checking the folder’s existence.

 

// this will create a folder 'Config' under 'Desktop\Automation\ProjetName' only if this folder does not exist

var configFile =ctx.fso.folder.getSpecialFolder(e.shell.specialFolder.Desktop) + "\\Automations\\"+ ctx.options.projectName + "\\config";
if (!configFile.exist){
	ctx.fso.folder.create(configFile);
}

Working Files

For temporary files used by the bot, Windows users may need some specific authorizations. The best practice is to create these files under the log folder of the project. This is the more convenient way to manage the working files.

//this will create a file  'TempFiles' in your project folder
ctx.fso.folder.create(ctx.options.path.log+"\\TempFiles\\") 

 

Managing folder Path using factory variables

 

When managing a common file/folder for a group of users who all have access to a shared repository. You can use the Cloud Factory text variable to store the path. then retrieve it in your script as in the example below.

For more information on CF variables check this link .

var mypath;
// ----------------------------------------------------------------
//   Step: get_path_var
// ----------------------------------------------------------------
GLOBAL.step({ get_path_var: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('Custom_getPathVar', 'c514ca1b-3d9d-445b-a2e3-069c9a7b9397') ;
	
	// Describe functionality to be implemented in JavaSript later in the project.
	
	// Declare setting path
	ctx.setting({ MyPath: {
		comment: "sc.localData.mytenant",
		server: true
	}});
	// Get setting
	ctx.settings.MyPath.get(function(code, label, setting) {
		if (code == e.error.OK) {
			// get value from setting.value
			mypath = setting.value;
			ctx.log(mypath);
			
		} else{
			ctx.log('Error during setting retrieval'); 
			sc.endStep(); // pSapGlobalCloud8L_man
			return;
											
		}
		sc.endStep(); // code_
	return;
	
	});
									
									
}}); 

Output files

In case your scenario requires one or many output files, a good practice is to create the output folder locally.

//this will create a folder 'output' under the path 'Desktop\Automations\ProjectName'
ctx.fso.folder.create(ctx.fso.folder.getSpecialFolder(e.shell.specialFolder.Desktop) + "\\Automations\\"+ ctx.options.projectName + "\\output")

Conclusion

Managing files can be challenging if no best practices are followed. By implementing these simple steps, you can make the development easier and the bot maintenance simpler.

Please comment with any feedback or additional input and thank you for reading.

 

 

 

 

 

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.