Parameter is the ID of the ticket record function getNotesData(noteIds) { try { let columns = [ search.createColumn({ name:… Continue reading How to perform user note search from custom record
Category: JavaScript
Filter duplicate emails from array
let noteRecepinets = [recepientEmail, recepient2, employee1, employee2, salesAssociateEmail]; let validnoteRecepinets = […new Set(noteRecepinets.filter(el => checkForParameter(el)))]; /** * Function to check the validity of a parameter. * @param {string|number} parameter … Continue reading Filter duplicate emails from array
Capitalizing Strings in JavaScript
/** * @description Capitalizes the first letter of a given string * @param {string} str – The string to capitalize * @returns {string|boolean} – Capitalized string or false if invalid */ function capitalizeFirstLetter(str) { if (typeof str !== “string” || str.length === 0) return false; return str.charAt(0).toUpperCase() + str.slice(1);… Continue reading Capitalizing Strings in JavaScript
Rounding Numbers in JavaScript
/** * @description Rounds a number to the specified decimal places * @param {number} num – The number to round * @param {number} decimals – Number of decimal places * @returns {number|boolean} – Rounded number or false if invalid */ function roundToDecimals(num, decimals) { if (typeof num !== “number” || typeof decimals !==… Continue reading Rounding Numbers in JavaScript
Checking if an Input is a Date Object
/** * @description Check whether the given value is a Date object * @param {any} dateObj – The value to check * @returns {boolean} – True if it’s a valid Date object, otherwise false */ function isInstanceOfDate(dateObj) { return dateObj instanceof Date && !isNaN(dateObj); } console.log(isInstanceOfDate(new Date())); // true console.log(isInstanceOfDate(“2024-02-28”)); // false (string,… Continue reading Checking if an Input is a Date Object
JavaScript code to Add/Subtract days from Date Object
let prevPremVal = null; // Initialize previous premium value customrecord_jj_new_commi_report_ahap29SearchObj.run().each(function(result) { let isPremium = result.getValue(result.columns[36]); // Check if it’s premium let tieredPremium = getTieredPremiumValue(result.getValue(result.columns[38]), result.getValue(result.columns[61])); log.debug(“Is Premium:”, isPremium); log.debug(“Tiered Premium:”, tieredPremium); // If isPremium is true and tieredPremium is valid, use tieredPremium //… Continue reading JavaScript code to Add/Subtract days from Date Object
Displaying Cable Length in Feet and Meters in the Cable Configuration Form
The client requires that cable length be displayed in both feet and meters within the cable configuration form. The length will be entered and stored in feet, while its equivalent in meters should be displayed alongside but remain non-editable. The conversion formula used for this purpose is: Length in Meters = Length in Feet ÷… Continue reading Displaying Cable Length in Feet and Meters in the Cable Configuration Form
Use Set to remove Duplicates from an Array
Set in JavaScript can easily remove duplicates from an array. A Set is a collection of values where each value must be unique. When you convert an array to a set, all duplicate values are automatically removed. Here’s an example: Example in JavaScript: // Original array with duplicates const arrayWithDuplicates = [1, 2, 3, 4,… Continue reading Use Set to remove Duplicates from an Array
20 Advanced JavaScript Tricks for Experienced Developers
Welcome to the world of advanced JavaScript! Whether you’re a seasoned developer looking to sharpen your skills or an enthusiast eager to dive deeper into the intricacies of JavaScript, this blog is designed to inspire and educate. Let’s explore 20 advanced JavaScript tricks that will not only enhance your coding prowess but also bring a… Continue reading 20 Advanced JavaScript Tricks for Experienced Developers
How Async/Await Can Slow Down Your Node.js App
In the world of Node.js, async/await has become a staple for handling asynchronous operations. It’s clean, easy to read, and feels synchronous. But as wonderful as it sounds, misusing async/await can introduce performance bottlenecks that slow down your application. If your app feels sluggish despite using async/await, this post is for you. Why Async/Await Feels Slow Under the hood,… Continue reading How Async/Await Can Slow Down Your Node.js App