Loading, please wait...



Perform String Manipulations in UIPath with example.

Jan 08, 2020 rpa, uipath, 899 Views
In this article, we will see the most common ways and examples of data manipulations.

In this article, we will see the most common ways and examples of data manipulations.we will also see using some of the most common data types that we will meet in realtime work, such as

  • Strings
  • Lists
  • Dictionaries
What is Data Manipulation?
Data Manipulation is the process of changing, formatting,structuring, sorting data in order to simplify its usage and easier to read.
 
Real-time Scenarios in which we will implement DataManipulation?
A bulk data could be organized in alphabetical order, making individual entries easier to locate. Let's say, we have a financial database, Data manipulation provides to extract only the relevant data and use it in other documents or correlate it with information from other sources.
 
Strings, What are they?
 Strings are the data types equivalent to the text. it is difficult to predict an automation scenario that doesn't encompass the use string.
There will situations like, a text that needs to be captured, processed, sent between applications, the string comes in handy.
 
Types of String Methods 
 Concat: It Concatenates the string representation of two specified objects.
               eg: String.Concat(Name1,Name2) 
 
 Contains: It Checks whether a specified substring occurs within a string and returns true or false.
               eg: Name.Contains("text") 
 
Format: It Converts the value of objects to strings (and inserts them into another text).
               eg: string.Format("{0} is {1}",Name1,Name2) 
 
IndexOf: It Returns the zero-based index of the first occurrence of a character in a string
               eg: Name1.Indexof("a") 
 
Join: It Concatenates the elements in a collection and displays them as String.
               eg: String.Join("|",Name1) 
 
Replace:  It Replaces all the occurrences of a substring in a string
               eg: Name.Replace("Orginal","replacewith") 
 
Split:  It Splits a string into substring using a given separator
               eg: Name.Split("|"c)(index) 
 
Substring:  It Extracts a substring from a string using the starting index and the length.
               eg: Name.Substring(startindex,length) 
 
 Full list of String methods, visit Microsoft .NET Portal
 
String Manipulation in UIPath 
 let's consider we have a process that includes two steps, extracting an address from Application A and entering it in different applications.
Problem 
 Assume, Application A has all of the pieces of information in a single field as below
 Hyderabad, Jublieehils,62/1
Solution 
Now the solution is to employ String manipulation methods to isolate the needed items, name city name, street name, and street number and put the result in individual fields in Application fields,
 
CityName = Hyderabad
StreetName = Jublieehils
Street number = 62/1 
  
 
Practical Solution
 
We'll build a sequence called SitesActive. The project we are about to create extracts some information from an input text and outputs in a different format. The input string is generated by an application that searches for aspecific writer and finds the sites active where his articles are available. The initial format is "You searched for author Rathrola". his articles can be found in the following sites "CsharCorner, Dzone, CodeProject". After the execution of the workflow, the format will be "Rathrola articles  published sites: CsharpCorner, Dzone, CodeProject".
 
 
Let's achieve the above solution using UIPath Studio, 
 
1) Open UIPath Studio and Click on New Process as shown below
 
 
 2) Give a name to the process, select the path to save this process file, write description text as you wish & click create button.
 
 
3) Click on main workflow, drag & drop sequence activity from activity pane a shown below,
 
 
 
 4) Now create a new variable to store the initial message as shown below,
 
 5) Drag& drop Assign activity from activity pane to determine the content of the variable, rename this to Assing initial message,
 
 
 6) Add the message variable in To field, and copy the text below to VB expression field, make sure you paste it in double-quotes.
"You searched for author Rathrola, his articles can be found in the following sites: CsharpCorner, Dzone,CodeProject",
 
 
 7)Now extract the author from the above message. To do this create another variable called the author and drag the assing activity to a workflow.
 
 8) Click on Expression Properties and using the Split method to extract the author from the message.
expression: message.Split("."c).First.ToString.Substring(message.LastIndexOf("author"))
 
 
 9) Now, let us move onto the list of strings, firstly let's create a variable called SitesActive and set its type to List<string>.
 
Create variable as shown below, 
 
 
 
Create variable type dropdown as shown below and select browse for types 
 result as below,
 
10) Drag& drop Assign activity from activity pane to designer panel tow rite an expression that extracts the sites active list, name it as site lists,
 
 11) Now assing sites active variable in To field and paste below expression in Properties value
expression:message.Split("."c).ToString.Split(":"C).Last.ToString.Split(","c).ToList
 
 
 
 12) Now we have to print a message to output panel, for that we need to create another variable to store the processed message as shown below,
 
 
 13) Drag and drop Assign activity to a designer panel, and assign output string variable in To field, edit the expression as below,
 expression: String.Format("Availablilty for {0}:{1}", author,String.Join(","+vbCr,SitesActive))
 
 vbCr is used to go on a new row for each element (similar to Environment.NewLine)
 
14) Now write the output string to a message box, to do so drag and drop Log message activity and assign output string variable as shown below 
 
 15) Run the project and check the output pane for results
 
 
Conclusion 
 
Have you ever tried creating an automation workflow in UIpath?Could you find this post useful? Let me know your valuable feedback and suggestions.
 
Happy Automation :)