Mashup Builder > Functions > Best Practices for Creating Function Expressions
Best Practices for Creating Function Expressions
The following functions and widgets support writing custom JavaScript expressions in a mashup:
Expression function—Evaluates to a value
Validator function —Evaluates to a Boolean value
Grid widgets—Evaluate user input when editing grid cells
Use the TW.log function for Development Purposes Only
You can use the TW.log() function to log debug, error, warning, and information messages related to expression in a mashup. Log messages are displayed in the mashup log dialog at run time. For example:
TW.log.debug('debug')
TW.log.error('error')
TW.log.warn('warn')
TW.log.info('info')
Opening mashups that contain a large numbers of expression logging statements impacts the mashup performance significantly. If you are using a large number of log statements in your mashups, we recommend that you avoid using them in a live production environment. You can use log statements while developing and testing a mashup, .but you should convert them into comment or remove them from the code before deploying the mashup to a production environment.
Check the Run Time Debug Console
After designing a mashup that contains expressions, check the debug information dialog box at run time. You can use this feature to trace the execution of your mashup, which helps you identity logic issues, such as circular bindings and infinite loops in your design or implementation. To view debug information for a mashup, click Show/Hide Debug Info on the run-time toolbar.
Parsing JSON Input
When working with JSON data in an expression, avoid using the JSON.parse() method to parse and convert JSON from a string. You can access JSON objects within parameters that are set to a JSON base type directly.
Was this helpful?