Skip to Content
Technical Articles
Author's profile photo Vishal Kumar Dubey

SAP Intelligent RPA – Use of Credential and Setting Activities (SAP iRPA Desktop Studio)

Introduction

In this blog post you will learn how to create and store environments, variables, and settings, and thus make the configurable scripts with the SAP Intelligent RPA Cloud Factory (aka SAP iRPA).

Purpose

This approach gives the flexibility to change the variables (credential or text) whenever required without changing the script. Therefore, it is very useful when credentials and URL (or other text information such as login language) are required at runtime without hardcoding.

Product

SAP Intelligent RPA version used: Desktop Studio 1.0.8.36

How it works

The below scenario is well suited when Environments are available from the debug mode.

Steps in action

1. Variable creation

There are following two types of variables in the Cloud Factory Environment

1.1. Credential: Use to store a username and a password

1.2. Text: Use to store a simple value (such as URL or login language)

1.3. Create and store the environments and variables as per the requirement

Here, there are following three variables created,

  1. system URL,
  2. store system credential, and
  3. system login language (this is not being used in this demo)

2. Desktop Agent setting

Select the environment in which the variables are created.

3. Workflow creation

The declaration can be kept either outside the scenario step or inside, i.e. both ways it is possible.

3.1 Variable declaration as Out of Scenario (recommended) – the declaration is out of scenario therefore declared variables will be accessible independent of steps execution.

3.2 Variable declaration as a Scenario Step – the declaration is local therefore declared variables will be accessible when declaration steps are executed.

4. Variable declaration within the workflow

4.1. Credential declaration

4.2. Setting declaration (handling Text Variable)

Generated code:

//---------------------------------------------------
// Declare system URL
//---------------------------------------------------
ctx.workflow('wf_LaunchApplication', 'eb0723d7-dd22-4093-ab04-c2561a664b79') ;
// Declare system URL

ctx.setting({ SystemURL: {
	comment: "My setting for URL",
	server: true
}});

//---------------------------------------------------
// Declare system credential
//---------------------------------------------------
ctx.workflow('wf_LaunchApplication', '053411d2-6176-476c-9527-a6e1ccb2f512') ;
// Declare system credential

ctx.cryptography.credential({ SystemCredential: {
	comment: "Username and Password",
	server: true
}});

//---------------------------------------------------
// Declare system language 
//---------------------------------------------------
ctx.workflow('wf_LaunchApplication', 'eb0723d7-dd22-4093-ab04-c2561a664c98') ;
// Declare system language 

ctx.setting({ SystemLanguage: {
	comment: "Login Language",
	server: true
}});

5. Retrieving variable value within the workflow

5.1. Get credential value

5.1.2. Create variable to store the data at runtime (rootData.URL, rootData.username and rootData.password)

Note: Local data declaration can also be used such as sc.localData.credential.user and sc.localData.credential.password

Generated code:

// ----------------------------------------------------------------
//   Step: Get_credential
// ----------------------------------------------------------------
Logon.step({ Get_credential: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('wf_LaunchApplication', '24ae4149-b225-4d53-afb7-04e0e4367f7c') ;
	// Get credential
	
	ctx.cryptography.credentials.SystemCredential.get(function(code, label, credential) {
		if (code == e.error.OK) {
			// TODO : set login/password here
			rootData.username = credential.userName.get();
			rootData.password = credential.password.get();
			
		  ctx.log("Username:" + rootData.username);
			ctx.log("Password:" + rootData.password);			
			sc.endStep(); // Start_Logon
			return;
		}
	});
}});

5.2. Get setting value (Text Variable)

// ----------------------------------------------------------------
//   Step: Get_setting
// ----------------------------------------------------------------
Logon.step({ Get_setting: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('wf_LaunchApplication', '6f806c6c-e08d-45fc-a07d-d7f0f1ac2079') ;
	// Get setting
	
	ctx.settings.SystemURL.get(function(code, label, setting) {
		if (code == e.error.OK) {
			// get value from setting.value
			rootData.URL = setting.value;
			
			ctx.log("URL:" + rootData.URL);
			sc.endStep(); // Get_credential
			return;
		}
	});
}});

5.3. Launching URL:

// ----------------------------------------------------------------
//   Step: Start_Logon
// ----------------------------------------------------------------
Logon.step({ Start_Logon: function(ev, sc, st) {
	var rootData = sc.data;
	ctx.workflow('wf_LaunchApplication', '15b60db0-e383-4833-b2b2-931ad8896e15') ;
	// Start 'Logon'
	Logon.navigator = e.navigator.Chrome;
	Logon.start(rootData.URL,null,null,e.launchFlag.ShowMaximized);
	sc.endStep(); // pLogon_management
	return;
}});

 

Conclusion

Now you should be able to create and store environments, variables and settings, and thus make the configurable scripts or your SAP iRPA project.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Avinash Y
      Avinash Y

      Hi Vishal,

      i have created the variables under test environment but At this point 2. Desktop Agent setting i am unable to see the environment drop down under settings in my desktop agent . is there any additional configuration required for this ?

      Do you have any idea about this ? please suggest

      Note:i am using the trial version Desktop studio 1.0.5.57

      Thanks

      Author's profile photo Vishal Kumar Dubey
      Vishal Kumar Dubey
      Blog Post Author

      Hi Avinash,

      Settings/Environment will be available when you run the solution/project and when Desktop Agent pops up then save the environment setting (can be switched if more than one available).

      For more details please have a look at the steps (step - 3) in the below blog.

      Configure Agents, Agent groups and Machine in SAP Intelligent RPA Cloud Factory

      Best regards,

      Vishal Kumar Dubey

      Author's profile photo Avinash Y
      Avinash Y

      Hi Vishal,

      Thanks for your quick response.

      when i use Get setting activity ,there are no values showing up in the drop down for the parameter "Setting Name ", what might be the reason ?? Attached screenshot FYR.

       

      Can you suggest me here ?

      Thanks,

      Avinash Y

      Avinash

      Author's profile photo Vishal Kumar Dubey
      Vishal Kumar Dubey
      Blog Post Author

      Hi Avinash,

      Used Desktop Studio Version may be one of the reasons (but I’m not sure).

      Anyways, using the below workaround you can proceed with this.

      1. Copy the Setting Name (Text variable name – used in Declare Setting / created in Environment variables)
      2. Right mouse click on the label ‘Setting Name’
      3. Use paste options and then you are done.

      Best regards,

      Vishal Kumar Dubey

      Author's profile photo Avinash Y
      Avinash Y

      Thanks Vishal Kumar Dubey for your quick response.

      Looks the trial around is not working as the value is not updating while pasting.

      i am currently using  version 1.0.5.57.

      Any other ways that we can fetch the values from cloud and storing into variables in the desktop studio.

      Regards,

      Avinash Y

       

      Author's profile photo Vishal Kumar Dubey
      Vishal Kumar Dubey
      Blog Post Author

      Hi Avinash,

      You can try with a custom-activity approach.

      // ----------------------------------------------------------------
      //   Step: Custom_
      // ----------------------------------------------------------------
      GLOBAL.step( {
      	Custom_: function (ev, sc, st) {
      		var rootData = sc.data;
      		ctx.workflow('CustomSettingGet', '2767f86b-7376-4ed7-9f23-ec8dee5f7ebb');
      
      		// Custom code start ==========>>>
      		ctx.settings.SystemURL.get(function (code, label, setting) {
      			if (code == e.error.OK) {
      				// get value from setting.value
      				rootData.url = setting.value;
      				ctx.log('URL ->' + rootData.url);
      			}
      		});
      		// Custom code end <<<==========
      
      		sc.endStep(); // end Scenario
      		return ;
      	}
      });
      
      // ******************************************************************************************
      // *************************** Out of Scenario treatments ***********************************
      // ******************************************************************************************
      
      //---------------------------------------------------
      // Declare setting
      //---------------------------------------------------
      ctx.workflow('CustomSettingGet', '91b94e31-5e2d-44f8-8d67-d5c3af26cfb6');
      // Declare setting
      
      ctx.setting( {
      	SystemURL: {
      		comment: "System URL",
      		server: true
      	}
      });

      Best regards,

      Vishal Kumar Dubey

      Author's profile photo Sulagna Chakraborty
      Sulagna Chakraborty

      Is it possible to set multiple variables in cloud foundry and use them in workflow?

      Author's profile photo Vishal Kumar Dubey
      Vishal Kumar Dubey
      Blog Post Author

      Hi Sulagna,

      Yes, it is possible.

      Best regards,

      Vishal Kumar Dubey

      Author's profile photo Marc Bertrand
      Marc Bertrand

      Hi Vishal,

      I use Desktop Studio 2.0.16.64.

      I defined in the cloud foundry a variable for the credentials.

      credentials%20variable%20in%20cloud%20foundry

      credentials variable in cloud foundry

      In Desktop Studio, I add the step "Get credential", assigned my variable to this step but it does request a username and password, see the screenshot below, which was not the case in your scheenshot. What should I do ?

      If I delete the step "Get credential", I can debug the workflow and in the desktop agent I can see that the environment QUAL is correctly selected.

      get%20credential%20in%20desktop%20studio

      get credential in desktop studio

      Author's profile photo Vishal Kumar Dubey
      Vishal Kumar Dubey
      Blog Post Author

      Hi Marc,

      Yes, you are right. As the product is growing, this is one of the improvements. Now you have the flexibility to assign username and password variables to store the value at runtime.

      Please find screenshots that will help you get the value of username and password.

      NOTE: After setting the variables username and password, BUILD the project which will generate the code.

       

       

       

       

      Regards,

      Vishal Kumar Dubey

      Author's profile photo Marc Bertrand
      Marc Bertrand

      Hi Vishal,

      I followed your procedure and it worked ! Thanks.

      Marc