Legacy Dev Forum Posts

 View Only

Sign Up

IF statement...dynamic variable?

  • 1.  IF statement...dynamic variable?

    Posted 06-05-2025 19:10

    VaunMcCarthy | 2020-09-07 07:08:17 UTC | #1

    I'm trying to figure out a way to have the following

    if variableA = true, then variableB = green, else variableB = red

    (for setting background color of another script object)

    Is there some way of doing this?


    anon28885283 | 2020-09-07 07:26:33 UTC | #2

    Yes, it should be possible. You'll need two variables: a boolean one, and a string dynamic variable (for the background color).

    Ex: {{BooleanVar}} {{BackgroundColor}}

    For the value of BackgroundColor, set it to:

    ifElse(equal({{BooleanVar}}, true), "#00ff00", "#ff0000")

    Then set the script component's background to the BackgroundColor variable.

    Here's a reference for the hex color codes if you're not familiar with it: https://htmlcolorcodes.com/


    VaunMcCarthy | 2020-09-07 19:44:52 UTC | #3

    Thanks, that looks like it will do what I"m after. Can I ask what are the language/syntax options within those dynamic variables? Other than ifElse and concatenating strings, what else is there that's available?

    I had tried to find some type of reference document but couldn't.


    anon28885283 | 2020-09-08 00:47:59 UTC | #4

    Here are some resource center articles about dynamic variables:

    https://help.mypurecloud.com/articles/dynamic-script-variables/ https://help.mypurecloud.com/articles/additional-functions-to-use-in-dynamic-variables/ https://help.mypurecloud.com/articles/expression-syntax-and-functions/ https://mathjs.org/docs/reference/functions.html


    system | 2020-10-09 00:48:00 UTC | #5

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 8757