ng:varToString

ng:varToString

The function,

ng:varToString('varName','encoding')
is a function that has been added especially for use with web services. The function converts the variable, varName (which is expected to be an integer) into a string.

This encodes the variable, hello as a UTF-8 string:
ng:varToString('hello', 'utf-8')
Both variable name and encoding are XPath expressions.
Notes
Please note that this is a magic variable, and it might have some limitations if used layered, e.g.:
ng:varToString(ng:varToString('hello','utf-8'),'iso-8859-1')

A related function is ng:payloadToString().

This built-in function was added as an aid for those, that wants to call external Http(s) rest apis. If the api expects a string, then this function can be used to convert a variable (with binary contents) into a string. An example for how this can be used is included here.

    • Related Articles

    • ng:payloadToString

      The function ng:payloadToString('encoding') is to be used in workflows only. It converts the payload into a string. The encoding can e.g. be 'UTF-8' like in this example: ng:payloadToString('utf-8') A related function is ng:varToString(). This ...
    • ng:decrypt

      The built-in function, ng:decrypt is linked with the encryption functions: ng:encrypt and the workflow component, Set secure workflow variable. The function, ng:decrypt() can decrypt contents, that was previously encrypted with these functions. The ...
    • ng:resourceExist

      This function checks, if a resource in InterFormNG2 exists or not. The function returns a boolean: true or false. The ng:resourceExist Xpath function has this format: ng:resourceExist(resource,path) where: resource Resource is the type of resource in ...
    • ng:minimum

      InterFormNG2 includes the special built-in XPath function, ng:minimum. This function returns the smallest value of two numeric arguments. The function only accepts two numeric arguments - no more and no less. Examples: ng:minimum(-14,2) returns: -14 ...
    • ng:spaceConcat

      The built-in function, ng:spaceConcat(), helps concatenate two strings with a space character automatically inserted between them. Here is an example: This XPath expression: ng:spaceConcat('First name:', 'Jon') outputs this string: First name: Jon ...