Use "execute-csharp" widget methods from regular functions

There are methods found in the “execute-csharp” widget, at lest in the configurator designer, that are used to get data from Lookup tables. Below is the signature. If I hover over the method it gives me a description that shows what it is using behind the scenes. I would like to use these from functions created on the server. In the function designer I can type Ice followed by the “dot” + “space” I don’t see MetaFx as an option. Any Ideas?

await PCLookUp.DataLookUp(string lookupTable, string columnName, string rowName)

Update: Found something by looking in the \Server\Assemblies folder. Still did not find a method called “PCLookUp” though.

I ended up just creating my own functions and they seem to work so far. It was a good learning experience anyway. This is my version of the Data Column Lookup List. I think the method used in app studio always returns the first column so “colReturnName” in not supplied in the screen shots below. Not sure if there is a more efficient way to get the value from the “Dbcontext.PcLookupTblValues…” query in the foreach loop. It seems like I could have gotten that data from the first “Dbcontext.PcLookupTblValues…” query and stored that in a variable for use inside the foreach loop. In this post @timshuwy comments below about doing a join, but not sure that applies for this example.

Note that becuase the lookup table is not a traditional table, you must join each separate column.



try {
  var Dbcontext = Ice.Services.ContextFactory.CreateContext <ErpContext> ();
  IEnumerable<int> rows;
    rows = Dbcontext.PcLookupTblValues.Where(tv => tv.LookupTblID == tableId && tv.ColName == colName).ToList().Select(tv => tv.RowNum);
  } else{
    rows = Dbcontext.PcLookupTblValues.Where(tv => tv.LookupTblID == tableId && tv.ColName == colName && tv.DataValue == searchValue).ToList().Select(tv => tv.RowNum);
  List <string> results = new List <string>();
  foreach(var row in rows) {
    var res = Dbcontext.PcLookupTblValues.FirstOrDefault(tv => tv.LookupTblID == tableId && tv.ColName == colReturnName && tv.RowNum == row);
    if (res != null) {
  output = results.Count > 1 ? string.Join("~", results) : results.FirstOrDefault();
} catch (Exception ex) {
  error = ex.Message;