Quick And Easy Epicor Data Lookups Via Code In Customizations

Have you found yourself needing to quickly look something up as a part of your customization? Is the customer on credit hold? Is that part in stock? While there are many ways to get this information including using BO calls, it can be a burden to set up all of that code for what should be a simple lookup. Fortunately, almost all business objects within Epicor contain the fabulous listLookup method which is lightning fast and can be called without defining specific reference to the associated business objects. Here is how it works within a customization (logic would be similar within a BPM):

// Define a variable that will easily let us know if any results were found bool recSelected = false; // Define the whare clause for the lookup. Whatever would work in a standard // SQL where clause will work here. string whereClause = "PartNum = '1234'"; // Here is where we actually call listLookup. The only thing you need to // ever change here is where we have "PartAdapter". DataSet dsPart = SearchFunctions.listLookup( oTrans, "PartAdapter", out recSelected, false, whereClause ); if (recSelected) { // dsPart will be filled here and you can loop through the rows in //dsPart.Tables[0].Rows }

As noted in the comments, the only things you will really be changing in this snippet would be the whereClause and which adapter you are using (i.e. PartAdapter, CustomerAdapter, SalesOrderAdapter, etc).