Replace a null value in a variable

Hi,

What would be the way of replacing a null value returned by a task ?

image

with a non null value such as one. Is it possible to do it via an expression ? As a workaround i have created an additional separate task

image

But ideally i would want to do this in one task. So if null, which is taken care of by a xor gateway, replace the null value with one, otherwise use the value returned by the task.

Thank you

Hi @Bisoux :wave:

Iā€™m not sure whether I fully understand your question.

If you simply want to use an expression to deal with a value that can be null, then you could use the if expression:

if (x != null) then x else "x was null so let's turn it into a string"

Hope it helps :slight_smile:

1 Like

I think you have understood my question though in my use case it would have to look something like,

= if(lasttaskId.taskId = null) then 1 else lasttaskId.taskId

I will have to test this when i get back to the office :nerd_face: The variable is used down the line on other tasks so i will need the variable to have 1 if the result returned by the preceding task is null.

Screen Shot 2022-03-11 at 7.50.01 PM