Skip to main content

Common Data Types and Conversion in UiPath Studio

What are data types?

As you can guess by the name, data types describe the kind of data a variable can hold. For example, if the data type is Int32, then the variable must hold an integer. Likewise, if the data type is a String, then the variable must hold a text.

Data types

Listed below are some of the most commonly used ones.

System.String

System.String stores texts. This type of data comes with many methods of data manipulation that will be explained in detail in another lesson, namely Data Manipulation with Strings in Studio.

Numeric(category)

 

These variables store numbers. There are different sub-types of numerical variables. For example:

  • Int32 - System.Int32 (signed integers): 10, 299, -100
  • Long - System.Int64 (long integers): 54354353430, -11332424D
  • Double - System.Double (allows decimals, 15-16 digits precision): 19.1234567891011

System.Boolean 

stores one of two value:  True or False

Collection(category)

Collections are largely used for handling and processing complex data. Some of the most encountered collections are:

  • Array - ArrayOf<T> or System.DataType[] stores multiple values of the same data type. The size (number of objects) is defined at creation.
  • List - System.Collections.Generic.List<T> stores multiple values of the same data type, just like Arrays. But unlike Arrays, the size is dynamic.
  • Dictionary - System.Collections.Generic.Dictionary<TKey, TValue> stores objects in the form of (key, value) pairs, where each of the two can be a separate data type.

DataTable 

represents variables that can store big pieces of information and act as a database or a simple spreadsheet with rows and columns.

Date and Time(category)

  • DateTime - System.DateTime stores specific time coordinates (mm/dd/yyyy hh:mm:ss).
    This kind of variable provides a series of specific processing methods like subtracting days, calculating time remaining vs. today, and so on.

    For example, to get the current time, assign the expression DateTime.Now to a variable of type DateTime.
  • TimeSpan - System.TimeSpan stores information about a duration (dd:hh:mm:ss). You can use it to measure the duration between two variables of the type DateTime.

    For example, you can save the time at the start of the process in one variable (of type DateTime), the time at the end in another (of type DateTime) and store the difference in a variable of type TimeSpan.

Conversion methods of Data Types

There will be scenarios where we'll need to change the data type of a variable to another form. For example, the conversion of an integer to a string or vice versa. In such cases, we can use the conversion methods available in Studio.

Below is a list of some of the most commonly used conversion methods.

Convert.ToString Method

This method converts the specified value to its equivalent string representation. For example, from an integer to String.


 Eg: StrVar = Convert.Tostring(IntVar)

 

Convert.ToInt32 Method

This method converts a specified value to an integer. For example, from a String to integer or from a floating-point number to integer.


Eg: 

IntVar = Convert.ToInt32(StrVar)

IntVar = Convert.ToInt32(DblVar) 


There's another method to convert a string to an integer - CInt(String)


Eg: IntVar = CInt(StrVar)

 

Double.ToString Method

 

This method converts the numeric value of a floating-point number to its equivalent string representation. 


Eg: StrVar = DblVar.ToString

 

Double.Parse Method

This method converts the string representation of a number to its floating-point number equivalent.


Eg: DblVar = Double.Parse(StrVar)

 

Boolean.ToString Method

This method converts the value of a Boolean to its equivalent string representation (either "True" or "False"). 


Eg: ToString()

 

Convert.ToBoolean Method

This method converts a specified value to an equivalent Boolean value. For example, coveting an integer to an equivalent Boolean value. 


Eg: Convert.ToBoolean(IntVar)

Convert Date and Time to String

This method converts the value of the specified DateTime object to its equivalent string representation.  

Eg: DateTimeVar.ToString("dd-MM-yyyy")

Most of the data types used in UiPath are borrowed from the Visual Basic.NET language and there are several methods to convert a data type from to another.

 

 Source: UiPath Academy

Comments

Popular posts from this blog

How to set Profile Attribute in Siebel Workflow

For setting the Profile Attribute in Siebel Workflow, follow below steps: Add Business Service box in workflow. Open Business Service properties. Set  SessionAccessService in Business Service Name. Set  SetProfileAttr in Method Name. Then click on Business Service and set Input Arguments as below: Against Name argument you will add your profile attribute name and against Value argument you will add value for the new profile attribute, it could be from Process Property or Literal.

How to call Popup Applet through Server Script in Siebel

Background: Based on the requirements you need to show data or reports on a popup applet. You can invoke popup applet using workflow (below business service will be used in business service step), applet server script or browser script and using vanilla method and setting field user properties. Procedure: Below is the script for calling popup applet through server script: if (MethodName == "MethodName") { var oServiceAF = TheApplication().GetService("SLM Save List Service"); var inputPropAF = TheApplication().NewPropertySet(); var outputPropAF = TheApplication().NewPropertySet(); inputPropAF.SetProperty("Applet Name","ABC Popup Applet"); inputPropAF.SetProperty("Applet Mode","6"); inputPropAF.SetProperty("Applet Height", "700"); inputPropAF.SetProperty("Applet Width", "700"); oServiceAF.InvokeMethod("LoadPopupApplet", inputPropAF, outputPropAF) return (CancelOperati...

How to create and publish Inbound Web Service in Siebel based on Workflow

Inbound Web Services: The Inbound Web Service allows an external system to call a Siebel published Web Service. You can publish a business service or a business process as a Web Service and generate a Web Service Definition Language (WSDL) file that an external system can import. The Inbound Web Services can only be published from Siebel C using SOAP-RPC binding. Source: Oracle Docs What Is The Difference Between Web Services and APIs? An API is an interface that allows you to build on the data and functionality of another application, while a web service is a network-based resource that fulfills a specific task. Yes, there’s overlap between the two: all web services are APIs, but not all APIs are web services. Both web services and APIs are — at their core — very useful and very much used today. However, it’s the web services associated with SOAP and/or Service Oriented Architecture which are falling out of favor. Source: NordicApis Process: Prepare the workflow which will serve as Si...