0
 Followers
3
 Likes

Coalesce function in built-in functions

Builtin & User functions
On our radar

Variable ?? DefaultValue


if the variable is empty / null the DefaultValue is assigned

Created on 26 Jan 2017
Comments (6)

I'm not sure I understand. A variable, by default, has the default value. Which is the default value for the variable's type if no explicit default is specified.

A default value would be assigned once when the variable is created.  It can still be set to null later on.  The coalesce function would at run-time instant decide whether to use a default value or not.

I still don't understand: when the variable is "created", i.e. when it is defined, it already gets the default value.

Kilian, I think what Bruno is trying to say is this:

Variable ?? AlternativeValue

If the variable is null, use the alternative value instead, i.e. Employee.FirstName ?? "N/A"

The thing is though, there are no NULL values in the Platform. So there's no way we can test for a NULL value, since they don't exist!

Here is my answer, my equivalent, using existing functions (an If statement).  Used for a dropdown that produced completely blank values if the titles were not set (Id = 0).  Resulting in: "Name - QA Inspector" or "Name - (Unknown Title)" depending on if a title was associated with the Name.

SyntaxEditor Code Snippet

ApproversList.Label + " - " + If(ApproversTitles.Label<>"",ApproversTitles.Label,"(Unknown Title)")
views
417
Followers
0