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
Author: Hannath Abdul
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
Summary Types in Saved Search
First you need to define a Group summary type for the field you want to use to group results. The summary results page displays a list of values for this grouped field. You can click a value to drill down each group of results. After you have defined a Group, you can define another summary… Continue reading Summary Types in Saved Search
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
Function to send email
const sendEmail = (author, recepinetsEmail, subject, body, relatedRecords) => { try { email.send({ author: author, recipients: recepinetsEmail, … Continue reading Function to send email
How to perform user note search from custom record
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
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
Add radio button in same line and set one as default
var radio1 = form.addField({ id: ‘custpage_radio’, type: serverWidget.FieldType.RADIO, label: ‘YEARLY’, source: ‘yearly’, … Continue reading Add radio button in same line and set one as default
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