Conditions

In TeamDesk there are a number of functions used to state conditions. In this topic you may find description of two functions that are used for this purpose more often than others: the If- and Case- functions.

If-Condition

This type of condition works in the same way as in various programming languages: if the specified condition is true, then one statement is executed, else another statement is executed. The form of the If-function in TeamDesk is the following:

If (Boolean condition1, result1, Boolean condition2, result2, ... ,
else-result)

The first value in brackets is the condition statement that should answer the Yes/No question (that is, the condition can only be true or false). The first and the second function arguments go in pair; these are the condition-result statements, used to define what condition is set and what result should occur if the condition is true. For example, the

If ([Project Budget] > 1 000 000, “VIP”) formula states that if the project budget exceeds $1 000 000, its type should be changed to VIP.

One If-function may contain an unlimited number of the condition-result pairs: all the conditions will be verified one by one until one of them is found true.

The final value in brackets is the else-component. It defines what statement should be executed if none of the specified conditions is true. For example, the If ([Client’s Country] = “USA”, 10, 50) function used in the [Delivery Cost] column, states that the delivery cost for domestic (USA) customers is $10, while for all other cases a $50 fee is applied.

The else-statement is optional; if you omit this component, then the else-result will be null. In the If ([Company Name] = “ABC Inc.”, true) function used for a [Black List] column, a condition may be set to blacklist all leads coming from the ABC Inc. company, while in all other cases lead records are not affected in any way.

When creating condition statements, make sure that the result- and else- statements produce the same type of data, and that the result correlates with the column type.

Case-Condition

This type of function is very similar to the If-function, but is used to verify the condition against multiple cases. Using multiple conditions in the If-function makes you repeat the same value several times, for example, If( [Client’s Country] = “USA”, 10, [Client’s Country] = “Canada”, 20, [Client’s Country] = “Ukraine”, 30, …).

To avoid this repetition, you may use the Case-function, which has the following form:

Case (condition expr, value1, result1, value2, result2, ..., else-result)

Here you have to state the condition (actually the first part of it) only once, and then enter the condition-verified value and the result. Again, the number of the condition value-result pairs is unlimited. During the process of calculation, the system checks whether the first conditional part equals any of the defined verified values and produces a corresponding result.

The example above may be written in the following form: Case ( [Client’s Country],“USA”, 10, “Canada”, 20, “Ukraine”, 30, 100), that is if client’s country is USA, the rate is 10, if Canada – 20, if Ukraine – 30, while for all other countries the rate is 100.

Next: Creating Formulas