budibase.notify.success("Message de succès")budibase.notify.error("Message d'erreur")budibase.notify.warning("Message d'avertissement")budibase.notify.info("Message d'information")budibase.API.searchTable({
tableId: "ta_TABLE_NAME",
query: {
equal: { field: "value" }
},
limit: 50,
sort: "created_at",
sortOrder: "descending"
}).then(r => console.log(r.data))budibase.API.saveRow({
tableId: "ta_TABLE_NAME",
field1: "value1",
field2: "value2"
}).then(r => console.log(r))budibase.API.fetchRow({
tableId: "ta_TABLE_NAME",
rowId: "ro_XXXXX"
}).then(r => console.log(r))budibase.API.fetchRow({
tableId: "ta_TABLE_NAME",
rowId: "ro_XXXXX"
}).then(row => {
return budibase.API.saveRow({
...row,
fieldToUpdate: "newValue"
})
})budibase.API.deleteRow({
tableId: "ta_TABLE_NAME",
rowId: "ro_XXXXX",
revId: "1-XXXXX"
})const el = document.createElement('div')
el.textContent = 'Content'
el.className = 'my-class'
document.querySelector('.container').appendChild(el)document.querySelector('.btn').addEventListener('click', (e) => {
e.preventDefault()
console.log('Clicked!')
})const el = document.querySelector('.element')
el.style.display = el.style.display === 'none' ? 'block' : 'none'const el = document.querySelector('.element')
el.style.backgroundColor = '#4CAF50'
el.style.color = 'white'console.log('Label:', variable)
console.table(arrayOrObject)setTimeout(() => {
// Code à exécuter
}, 3000) // 3 secondesconst id = setInterval(() => {
// Code répété
}, 5000) // 5 secondes
// Arrêter: clearInterval(id)if (condition) {
// Si vrai
} else {
// Si faux
}const user = budibase.auth
console.log(user.email)
console.log(user.roleId)// Récupération
const data = {
name: document.querySelector('#name').value,
email: document.querySelector('#email').value
}
// Validation
if (!data.name || !data.email) {
budibase.notify.error("Champs manquants")
return
}
// Email valide
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(data.email)) {
budibase.notify.error("Email invalide")
return
}
// Sauvegarde
budibase.API.saveRow({
tableId: "ta_contacts",
...data,
submitted_at: new Date().toISOString()
}).then(() => {
budibase.notify.success("Envoyé !")
document.querySelector('form').reset()
})budibase.API.searchTable({
tableId: "ta_products",
limit: 100
}).then(result => {
let html = '<table><thead><tr>'
// En-têtes
Object.keys(result.data[0]).forEach(key => {
if (!key.startsWith('_')) {
html += `<th>${key}</th>`
}
})
html += '</tr></thead><tbody>'
// Lignes
result.data.forEach(row => {
html += '<tr>'
Object.entries(row).forEach(([k, v]) => {
if (!k.startsWith('_')) {
html += `<td>${v || '-'}</td>`
}
})
html += '</tr>'
})
html += '</tbody></table>'
document.querySelector('#container').innerHTML = html
})budibase.API.searchTable({
tableId: "ta_orders",
limit: 1000
}).then(result => {
const stats = {
total: result.data.length,
active: result.data.filter(i => i.status === 'active').length,
completed: result.data.filter(i => i.status === 'completed').length
}
const html = `
<div class="stats">
<div><h3>Total</h3><p>${stats.total}</p></div>
<div><h3>Actifs</h3><p>${stats.active}</p></div>
<div><h3>Terminés</h3><p>${stats.completed}</p></div>
</div>
`
document.querySelector('#stats').innerHTML = html
})query: {
equal: {
status: "active",
type: "premium"
}
}query: {
notEqual: {
status: "deleted"
}
}query: {
range: {
price: {
low: 10,
high: 100
}
}
}query: {
string: {
name: "search term"
}
}query: {
empty: {
description: true
},
notEmpty: {
email: true
}
}{
email: "user@example.com",
roleId: "ADMIN",
_id: "us_xxxxx",
firstName: "John",
lastName: "Doe"
}{
id: "component_id",
type: "custom",
styles: {...}
}{
appId: "app_xxxxx",
name: "My App",
url: "/app/my-app"
}{
path: "/current/path",
params: { id: "123" },
query: { search: "term" }
}✅ Toujours gérer les erreurs
.then(result => { /* succès */ })
.catch(error => {
console.error(error)
budibase.notify.error("Erreur")
})✅ Valider les données
if (!data.field) {
budibase.notify.error("Champ requis")
return
}✅ Donner du feedback
budibase.notify.success("Action réussie")✅ Logger pour déboguer
console.log('Debug:', variable)✅ Tester avec onClick d'abord
Mode: onClick → Test → Passer à onMount
- Activez "Accès au contexte Budibase"
- Choisissez le mode :
onMount- Auto au chargementonClick- Manuel via boutononInterval- Périodique
- Collez votre code JavaScript
- Testez !
MEMORA Solutions
- Stéphane Lapointe
- stephane@memora.ca
- https://memora.solutions
Version 1.0.0 - MIT License