Hi everyone,
Today, we'll look at how to compare different data types. Like other programming languages, Deluge supports seven different kinds of data types -- String, Bigint, Decimal, Timestamp, Boolean, List, and Map. To perform particular actions, we often try to compare or match two different data types.
Let's look at a simple example:
In the below given IF condition, we are trying to check if the left expression which is a text field is equal to "Jack".
- if (input.name == "Jack")
- {
- alert "Hi Jack";
- }
As both the expressions are of the same data type, the code works perfectly fine.
But, if we try to match the value in a text field(of type string) with a integer, we would get an error: In Criteria left expression is of type STRING and right expression is of the type BIGINT.
- if(input.name == 2 )
- {
- alert "Hi Jack";
- }
Another common scenario:
Users often get this error when they try to compare a Lookup value with a string. To explain this we have created two forms -- New Order Form and Record Inventory Details Form.
New Order Form - Allows you to place an order for a new product.
Record Inventory Details - Stores the information about the products you have in your inventory.
The Select Product Field in the New Order form is a Lookup field that displays product names fetched from the Record Inventory Details form.
Case 1: Here we will use Fetch Records task to fetch records from a Record Inventory Details Form and use it to auto-populate the price based on the product selected(Product_Name) from the drop down(which is a Lookup). But, we get an error as shown below.
Note: itemDetails is a collection variable which is used to store all the details of that particular product.
This is because the Lookup Field will lookup the ID of that particular record in the source Form.
Solution: Hence, to avoid this error, we need to compare the Lookup field value to the ID of base record in source form as shown in below screenshot. You can also explore our Learn Deluge Tutorial to know more about other Deluge tasks.
Hope you got a fair idea on how to compare different data types and use Lookup field to perform particular actions. Keep watching this space for more such tips.