Error on trying to assign a value to the field: Type 'number' is not assignable to type 'string'

Symptoms

Error on trying to assign a value to the field:

Type 'number' is not assignable to type 'string'

Cause

Field type differs from the type of value that is assigned to the field's value.

Resolution

Try converting the value to the necessary type prior to assigning it to the field.

I.e., if the value needs to be converted to string, use .toString() method. The method can be used as follows:

Have more questions? Submit a request

Comments

1 comment

  • Avatar

    Enno Duenkel

    I needed it a bit different
    I needed to compare the sum of weights to a string field - so my IF condition was the following:

    if (parseFloat(Context.GetField("Total weight").Text) - sum == 0) {
      ...
    }

    (sum=decimal variable, Total weight = name of the string field)

    0

Please sign in to leave a comment.