Aller au contenu principal

Backquote in string

Commentaires

4 commentaires

  • Ken Lyon

    Niluka Munasinghe That expression will still work, but the new error is caused indirectly by a change in v5.43. It will be resolved in v5.45.

    The quick answer is that you can add “.toString()” after the “.numeric” part to eliminate the error. It will be fixed in v5.45.

    Here are more details, in case you're interested.

    The change that is causing this to show an error where it did not before is the new validation of parameter types within expressions. That validation gives an error if you attempt to pass in a parameter of the wrong type to a function, for example:

    ="aaa".charAt("a")

    In this case, the parameter is supposed to be a number, but is actually a string.

    You might wonder what your expression has to do with this as you don't call any functions. It is to do with the version of JavaScript that the expression is being converted into. When you save your workflow, your expression gets translated into this:

    "".concat($formElementValueAdd2.value, " x").concat($mainForm.state.numberPE1.value.numeric)"

    For the longest time, we have been converting expressions to an old version of JavaScript to ensure it works in lots of types of browser. The use of template literals is a relatively new thing, so the strings were converted to use String.concat(). As you might have guessed, that method expects all of the parameters to be strings. This is where the error comes from.

    The 5.45 release of Workflow will target a newer version of JavaScript when entering expressions and your use of template literals will not be converted.

    Note that you will still need to edit the expression to force the designer to convert it to the new syntax.

    3
  • Niluka Munasinghe

    I appreciate your swift reply and thorough explanation. I will revise the expressions accordingly.

    Also need clarification about v5.45. Does that mean we'll have to update all the expressions with template literals in existing workflows?

    0
  • Ken Lyon

    Niluka Munasinghe Your workflows will continue to run correctly, but anywhere you see that “Expected parameter of type ‘string’…” message, you will need to edit the expression to convert it. This can be as simple as adding a space then deleting it.

    0
  • Niluka Munasinghe

    Thanks for the clarification, Ken.

    0

Vous devez vous connecter pour laisser un commentaire.