Restrict inserting a new sales team line using insert, when existing line has a specific employee

 function validateInsert(scriptContext) {       try {         let currentSublist = scriptContext.sublistId         if (currentSublist == ‘salesteam’) {           let rec = scriptContext.currentRecord;           let lineCount = rec.getLineCount({ sublistId: ‘salesteam’ });           for (let i = 0; i < lineCount; i++) {             let employeeId = rec.getSublistValue({               sublistId: ‘salesteam’,               fieldId: ’employee’,               line: i             });             if (employeeId && employeeId.toString() === TARGET_EMPLOYEE_ID && checkForParameter(role) &&… Continue reading Restrict inserting a new sales team line using insert, when existing line has a specific employee

Restrict roles from selecting values from a field by showing alert

function performTradePartnerOrderValidation(currentRec) {             try{         let newsalesOrderType = currentRec.getValue({           fieldId: ‘custbody52’         });         if(salesOrderType == SALES_ORDER_TYE_OBJECT.TRADE_PARTNER_ORDER && salesOrderType != newsalesOrderType && mode == ‘edit’ && !Object.values(TRADE_PARTNER_ORDER_LOCK).includes(role)) {           alert(“You cannot change the trade partner order. Please contact Administrator for details.”);           currentRec.setValue({             fieldId: ‘custbody52’,             value: salesOrderType           });           return false;         }         return true       }       catch(err) {         console.error(‘error@performTradePartnerOrderValidation’, err)       }… Continue reading Restrict roles from selecting values from a field by showing alert

Trigger Last Modified Date when email is sent and received via Email Tab

 function checkForParameter(parameter) {             try {                 if (parameter !== “” && parameter !== null && parameter !== undefined && parameter !== false && parameter !== “null” && parameter !== “undefined” && parameter !== ” “ && parameter !== ‘false’ && parameter !==… Continue reading Trigger Last Modified Date when email is sent and received via Email Tab

Search to get sales orders that does not have at least any of the given items

var salesorderSearchObj = search.create({ type: “salesorder”, filters: [ [“type”,”anyof”,”SalesOrd”], “AND”, [“cogs”,”is”,”F”], “AND”, [“shipping”,”is”,”F”], “AND”, [“taxline”,”is”,”F”], “AND”, [“datecreated”,”within”,”3/1/2025 12:00 am”,”3/10/2025 11:59 pm”], “AND”, [“sum(formulanumeric: CASE WHEN {item.internalid} IN (36496,36473,36470,36488,36486,36476,36490,36499,36477,36475,36483,36481,36479,36498,36480,36368,36492,36491,36494,36487,36482,36489,36627,36469,36485,36484,36478,36495,36472,36471,38291,36493,675,676,677,678,680,681,682,683,684,685,686,687,688,38311,691,693,694,36194,38287,38285,695,696,697,698,699,36188,700,38289,38290,36185,36186,707,708,36628,36189,711,713,714,36191,717,719,36363,720,721,36184,722,726,621) THEN 1 ELSE 0 END)”,”equalto”,”0″] ], columns: [ search.createColumn({ name: “tranid”, summary: “GROUP”, label: “Document Number” }), search.createColumn({ name: “internalid”, summary: “GROUP”, label: “Internal ID” }), search.createColumn({… Continue reading Search to get sales orders that does not have at least any of the given items

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

Call suitelet through post request using after submit in UserEvent Script

  const afterSubmit = (scriptContext) => {             if (scriptContext.type !== scriptContext.UserEventType.EDIT) return;             try {                 let noteRecord = scriptContext.newRecord;                 let noteId = noteRecord.id;          … Continue reading Call suitelet through post request using after submit in UserEvent Script