
Top Ten Corvid Tips
Updated: Jul 27, 2020
Check out these top ten tips as written by Corvid Master Salman.
Tip #1
Use a consistent name
Consistent naming of element ID, variable and function name will improve the readability of the code and easy to re-write the code. A great way to set the name of the element is to write what type of element it is (input, dropdown, checkbox, box or stripe) and their placeholder. This way, when you want to select a dropdown in the code just type in drop and IntelliSense will show all the dropdown elements. Example :
input element to get the first name => inFirstName
input element to get the last name => inLastName
checkbox to select product names => checkProd
box containing form => boxForm

Tip #2
Wait for the dataset to ready
Make sure all the datasets ready, before running the init code. This code is useful if you have more than one dataset.
$w.onReady(function() {
let dataset1, dataset2, dataset3;
$w('#dataset1').onReady(()=>{
dataset1 = true;
AllDatasetReady()
});
$w('#dataset2').onReady(()=>{
dataset2 = true;
AllDatasetReady()
});
$w('#dataset3').onReady(()=>{
dataset3 = true;
AllDatasetReady()
});
functionAllDatasetReady() {
if(dataset1 && dataset2 && dataset3) init();
}
});
functioninit() {
// all the dataset is ready
}
Tip #3
Top three key shortcuts to remember
Ctrl + Space - Open the intellisense
Alt + Up / Alt + down - move the line of code up/down
Alt + Shift + Up / Alt + Shift + down - copy the line of code up/down
More Shortcuts available here.
Tip #4
Step by Step to create a new feature or project
Before you start a project:
Design the database structure Simple pen/note or whiteboard is fine but also if you want there is a number of database design editors online available for free: https://sqldbm.com/Home/
Design UI Create all the pages and dynamic pages, drag and drop the element and update the property ID.
Start Writing code After you finish the first two steps it becomes easier to write the code.
Tip #5
Use a Comment
One word comment is more useful, keep the comment as short and precise as possible
// global Variable
let brand = "code queen";
$w.onReady(()=>{
// initialize the code
init(); // event
$w('#input').onKeypress(e=>{
// submit the form on "enter" key press
if(e.code === "Enter") {
}
});
$w('#dataset').onBeforeSave(e=>{
// insert the full name before form save
let fullName = e.firstName + e.lastName; $w('#dataset').setFieldValue("fullName" , fullName);
});
});
Tip #6
Debug using Site events
All the logs, error both in the page and backend will be shown in the live site will update in the site event. To open the Site event:
Go to Dashboards
Click on Setting
Site Monitoring (Under Product tools)
Click on the open button

Tip #7
Using try/catch with async/await
Using try/catch with async/await will help you to write clean, readable and error handling code.
asyncfunctionhandlePayment() {
try {
let user =