docs/versioned_docs/version-2.50.0-LTS/app-builder/walkthrough/using-code.md
In ToolJet, code serves as a powerful means to enhance and customize your applications. From complex logic implementations using Run JavaScript code or Run Python code queries to simple dynamic expressions with fx, the versatility is immense. Below is a basic demonstration of how you can leverage code within ToolJet.
Let's take a look at different examples on how to use code.
fx button next to the Disable condition.Disable condition:{{components.numberinput1.value ? false : true}}
//replace numberinput1 with the name of your check box component
Now if there is no value entered in the Number Input component, the button will be disabled.
You can apply the same principles to programmatically set a range of properties.
{{components.textinput1.value == "available" ? '#375FCF' : '#FF0000'}}
//replace textinput1 with the name of your check box component
{{components.checkbox1.value ? true : false}}
//replace checkbox1 with the name of your check box component
Columns, click on a column name.Transformations, the default value will be {{cellValue}}. Add JavaScript code to update the cell value dynamically.{{cellValue > 4.5 ? 5 : 4}}
await queries.restapi1.run();
// replace restapi1 with your query name
let value = queries.restapi1.getData();
// replace restapi1 with your query name
function filterProductsByBrandAndRating(value.products, brand, minRating) {
return products.filter(product => product.brand === brand && product.rating >= minRating);}
return filterProductsByBrandAndRating(value.products, "Apple", 4.5)
//use JavaScript code to refine the data
Default value, enter the below code:{{moment().format('DD/MM/YYYY');}}
The above code will add today's date as the default in DD/MM/YYYY format.
Globals accordion to check all the values available under global. These properties can be used to make your app more dynamic.Visibility property and enter the below code to make the button visible only when admins access it:{{globals.currentUser.groups.includes("admin") ? true : false }}
The examples provided are just a starting point for leveraging ToolJet's custom code capabilities. You have the flexibility to fully tailor your applications using our comprehensive custom coding features.