REGEXP_REPLACE(TO_CHAR({datecreated}, ‘DD.MM.YYYY HH24:MI’), ‘[^0-9]’, ”)
Author: Pranav Prakash
Suitescript code to parse XML data to JSON
function no_fast_endings(x) { x = x.split(“/>”); for (var i = 1; i < x.length; i++) { var t = x[i – 1].substring(x[i – 1].lastIndexOf(“<“) + 1).split(” “)[0]; x[i] = “></” + t + “>” + x[i]; } ; … Continue reading Suitescript code to parse XML data to JSON
jQuery to disable button action
To disable a button action using jQuery, you can set the attribute of the button to . Here’s a simple example: jQuery(‘#button_id’).prop(‘disabled’, ‘disabled’);
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
Javascript function that makes easier to replace multiple occurrences of a substring.
replaceAll() makes it easier to replace multiple occurrences of a substring. const signal = “Batman! Batman must respond!”; console.log(signal.replaceAll(“Batman”, “Bruce”)); // “Bruce! Bruce must respond!”
Javascript statement allows shorthand access to an object’s properties
The with statement allows shorthand access to an object’s properties but is generally discouraged due to ambiguity in scope. const obj = { name: “Bruce”, city: “Gotham” }; with (obj) { console.log(name, city); // “Bruce Gotham” }
Saves search formula to display sate in a state format
Add the following column in the search search.createColumn({ name: “formulatext”, formula: “TO_CHAR({trandate},’DD/MM/YYYY’)”, label: “Expiry Date” })