Category: How do I do X?


This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How do I use Smart JSON Substitution on Appsmith?


As an Appsmith user, I am having trouble with type casting in my code snippets. While one snippet works, another one doesn't. I am curious about what smart JSON substitution does and how I can use it in Appsmith.


The solution involves enabling the Smart JSON Substitution feature on Appsmith, which allows dynamic type conversions on field values in a request body. This can be done by toggling the Enable Smart Substitution option in the settings tab from the query pane.

To use Smart JSON Substitution, the following code snippet can be used where otaBookingId is a form field:

OTABookingId: {{otaBookingId.text===""?{$exists:true}:otaBookingId.text}}

However, for type casting issues, the following code snippet may not work:

{{otaBookingId.selectedOptionValue === undefined ? {$exists:true}:{$eq : otaBookingId.selectedOptionValue} }}

In this case, it may be helpful to use a ternary operator for the type conversion instead:

{{otaBookingId.selectedOptionValue === undefined ? {$exists:true} : (otaBookingId.selectedOptionValue + '') }}

This converts the value to a string, which can be used in the request body.