Database Normalization In the realm of database management, ensuring data efficiency and integrity is paramount. Database normalization is a systematic approach designed to minimize data redundancy and improve data consistency. It involves organizing a database into multiple related tables while following a set of rules, or normal forms, to streamline data storage and retrieval. Why… Continue reading Database Normalization
Tag: coding best practices
Convert Seconds to HH:MM:SS
function secondsToHMS(seconds) { const h = Math.floor(seconds / 3600); const m = Math.floor((seconds % 3600) / 60); const s = seconds % 60; return `${h.toString().padStart(2, ‘0’)}:${m.toString().padStart(2, ‘0’)}:${s.toString().padStart(2, ‘0’)}`; } console.log(secondsToHMS(3661)); // Output: “01:01:01”
Deep Clone an Object
function deepClone(obj) { return JSON.parse(JSON.stringify(obj)); } const original = { a: 1, b: { c: 2 } }; const clone = deepClone(original); clone.b.c = 3; console.log(original.b.c); // Output: 2
Truncate Text with Ellipsis
function truncateText(text, maxLength) { if (text.length > maxLength) { return text.substring(0, maxLength) + ‘…’; } return text; }
Format Numbers in Indian Numbering System
function formatIndianNumber(amount) { let formatted ; // Parse the number to two decimal places if(amount){ formatted = parseFloat(amount).toLocaleString(‘en-IN’, { minimumFractionDigits: 2, maximumFractionDigits: 2 … Continue reading Format Numbers in Indian Numbering System
SuiteScript Best Practices
Always thoroughly test your code before using it on your live NetSuite data. Type all record, field, sublist, tab, and subtab IDs in lowercase in your SuiteScript code. Prefix all custom script IDs and deployment IDs with an underscore (_). Do not hard code any passwords in scripts. The password and password2 fields are supported… Continue reading SuiteScript Best Practices
To Make Code Portable
We can create a constants library file like below and add internal ids in objects for different environments.