Saved search formula to get all the purchase order which does not have any item contains a specific class.

filters:[[“custbody27”, “anyof”, “2”],“AND”,[“custbody28”, “noneof”, “@NONE@”],“AND”,[“status”, “anyof”, “PurchOrd:F”, “PurchOrd:G”],“AND”,[“mainline”, “is”, “F”],“AND”,[“type”, “anyof”, “PurchOrd”],“AND”,[[“systemnotes.date”, “on”, “yesterday”], “AND”,[“systemnotes.newvalue”, “is”, “Pending Bill”], “AND”,[“systemnotes.field”, “anyof”, “TRANDOC.KSTATUS”], “AND”,[“systemnotes.type”, “is”, “F”]],“AND”,[“closed”, “is”, “F”],“AND”,[“max(formulanumeric: CASE WHEN {item.custitem_aha_parent_class}=’Accessory’ THEN 1 ELSE 0 END)”, “equalto”, “0”]],columns:[search.createColumn({name: “internalid”,summary: “GROUP”,label: “Internal ID”}),search.createColumn({name: “custbody28”,summary: “GROUP”,label: “End Destination”})]

Setting the value of custom record.

record.submitFields({type: ‘customrecord_jj_open_box_item_log1108’,id: openBoxId,values: {‘custrecordjj_item_sold_openboxlog1203’: true,‘custrecord_jj_so_number_openboxitem1749’: saleOrderId,‘custrecord_jj_so_date_openboxitem1749’: soCreateDate}});

Custom saved search to get salesorder details comparing value from custom record.

define([‘N/record’, ‘N/search’, ‘N/format’],/**/ (record, search, format) => { “use strict” /** Get sales order details.* @returns {Array} Array of sales order details.*/function getSalesDetails(openBoxSNumber,openBoxDate,openBoxItem) {try {let salesorderSearchObj = search.create({type: “salesorder”,filters:[[“status”, “noneof”, “SalesOrd:H”, “SalesOrd:C”],“AND”,[“type”, “anyof”, “SalesOrd”],“AND”,[“custcol11”, “is”, openBoxSNumber],“AND”,[“datecreated”, “after”,openBoxDate ],“AND”,[“item”,”is”,openBoxItem],“AND”,[“mainline”,”is”,”F”],“AND”,[“cogs”,”is”,”F”],“AND”,[“taxline”,”is”,”F”],“AND”,[“shipping”,”is”,”F”]],columns:[search.createColumn({ name: “type”, label: “Type” }),search.createColumn({ name: “internalid”, label: “Internal ID” }),search.createColumn({ name: “custcol11”, label: “Open Box/Display Serial… Continue reading Custom saved search to get salesorder details comparing value from custom record.

Saved Search to get the purchase order which changed the status to pending billing on yesterday.

let purchaseorderSearchObj = search.create({type: “purchaseorder”,filters:[[“custbody27”, “anyof”, “2”],“AND”,[“custbody28”, “noneof”, “@NONE@”],“AND”,[“status”, “anyof”, “PurchOrd:F”],“AND”,[“item.class”, “noneof”, “57”, “110”],“AND”,[“item.custitem_jj_product_type”, “noneof”, “3”],“AND”,[“mainline”, “is”, “F”],“AND”,[“type”, “anyof”, “PurchOrd”],“AND”,[[“systemnotes.date”, “on”, “yesterday”], “AND”,[“systemnotes.newvalue”, “is”, “Pending Bill”], “AND”,[“systemnotes.field”, “anyof”, “TRANDOC.KSTATUS”], “AND”,[“systemnotes.type”, “is”, “F”]]],columns:[search.createColumn({name: “internalid”,summary: “GROUP”,label: “Internal ID”}),search.createColumn({name: “custbody28”,summary: “GROUP”,label: “End Destination”})]});let searchResultCount = purchaseorderSearchObj.runPaged().count;

Search to get the item list from purchase order

let poSearch=search.create({type: search.Type.PURCHASE_ORDER,filters: [‘internalid’, ‘is’, poId],columns: [‘item’,’quantity’],});let itemRows = [];poSearch.run().each(function (results) {let item = results.getText(‘item’);let quantity = results.getValue(‘quantity’);if (item && quantity) {itemRows.push({ item, quantity });}return true});

Get the location prefix using search

let locationSearchObj = search.create({type: “location”,filters:[[“internalId”, “is”, location],columns:[search.createColumn({name: “formulatext”,formula: “CASE WHEN {tranprefix} IS NOT NULL THEN {tranprefix} ELSE {namenohierarchy} END”,label: “Location”})]});let searchResultCount = locationSearchObj.runPaged().count;if (searchResultCount <= 0) return false;let locationDetails = [];locationSearchObj.run().each(function (result) {let locationObj = {};locationObj.prefix = result.getValue({name: “formulatext”,formula:”CASE WHEN {tranprefix} IS NOT NULL THEN {tranprefix} ELSE {namenohierarchy} END”,label: “Location”,});locationDetails.push(locationObj);return true;});

Saved Search to show purchase order which has a non-blank End Destination and items that don’t fall under the “Accessory” or “Parts” category.

let poSearchObj = search.create({type: “purchaseorder”,filters:[[“custbody27”, “anyof”, “2”],“AND”,[“item.custitem_aha_parent_class”, “noneof”, “57”, “58”, “59”, “60”, “61”,“62”, “63”, “64”, “65”, “66”, “257”, “110”, “111”, “112”],“AND”,[“type”, “anyof”, “PurchOrd”],“AND”,[“custbody28”, “noneof”, “@NONE@”],“AND”,[“mainline”, “is”, “T”]],columns:[search.createColumn({ name: “internalid”, label: “Internal ID” }),search.createColumn({ name: “tranid”, label: “Document Number” }),search.createColumn({ name: “custbody27”, label: “PO Type” }),search.createColumn({ name: “custbody28”, label: “End Destination” })]});let searchResultCount = poSearchObj.runPaged().count;if (searchResultCount… Continue reading Saved Search to show purchase order which has a non-blank End Destination and items that don’t fall under the “Accessory” or “Parts” category.