UD Table BPM error NotSupportedException

Hi all,
Need some help with a BPM i have seen this on a old thread but no answer to my similar issue,
my snytx for BPM comes back with no error but when I run the PM through UBAQ i get a error message for the following “BPM runtime caught an unexpected exception of ‘NotSupportedException’ type.
See more info in the Inner Exception section of Exception Details.”

here is my BPM, I’m sure I’m missing something easy , I just very limited C# experience to address this issue .

foreach (var tt in ttUD38.Where(tt => !tt.Unchanged()))
{
var partData = Db.Vendor.Where(P => tt.Company == P.Company && tt.Key2 == Convert.ToString(P.VendorNum)).Select(P => new{P.Name}).FirstOrDefault();
if (partData != null)
{
tt[“ShortChar09”] = partData.Name;
}
}

Here is the syntax I use for stepping through the ttresults:

foreach (var ttResults_iterator in (from ttResults_Row in ttResults where ttResults_Row.Unchanged() select ttResults_Row)) // for every line in the BAQ results do this stuff...
{
}

Here is an example of pulling the resource group, this would happen within the above for statement brackets:

ResourceGroup = (from ResourceGroup_Row in Db.ResourceGroup where ResourceGroup_Row.Company == Session.CompanyID  select  ResourceGroup_Row).FirstOrDefault();

Hi Nate,
Thanks for the quick reply, I hate to bug you on this one, do you mind showing me what the code should look like given the example I have provided above. Again I’m a bit lost on this one.

I think we need a bit more information about what you are trying to do. Is ttUD38 coming from a BAQ? What’s the goal?

I’m just trying to copy the data from Vendor.Name or POHeader.Entryperson saved to UD38.ShortChar01 and UD38.ShortChar02

Hopefully this will shed some light on the subject. I have an UBAQ when you enter Key1 as the PONum and Key2 as the PartNum hit save Get list. the UBAQ will display data pertaining to those keys. My issue is that I need to create a data directive email alert and since the email data can only be pulled from table UD38. I’m not able to display the data from Vendor table and POheader to copy over to the UD38 ShortChar filed successfully without a Pre-processing method directive

I have a working method data directive to pull in the part information, but when I try to use the same syntax and run through the UBAQ I get a “NotsupportedException” error message when I try to the UBAQ

Posited below is my working syntax and the one that is not working to pull data from the Part table ( Pre-Processing method directive). But doesn’t work for POHeader or Vendor table The only issue I can see the difference is Key1 and PONum or VenorNum are int. So my original post does include a “Convert.ToString”

What else am I missing to avoid getting the notsupootedexepction messagae

Working Method directive to pull data form part table:

foreach (var tt in ttUD38.Where(tt => !tt.Unchanged()))
{
var partData = Db.Part.Where(P => tt.Company == P.Company && tt.Key2 ==(P.PartNum)).Select(P => new{P.PartDescription, P.ProdCode}).FirstOrDefault();
if (partData != null)
{
tt[“ShortChar04”] = partData.PartDescription;
tt[“ShortChar03”] = partData.ProdCode;
}
}

Failed method directive to pull data from Vendor or POeader table

foreach (var tt in ttUD38.Where(tt => !tt.Unchanged()))
{
var partData = Db.Vendor.Where(P => tt.Company == P.Company && tt.Key2 == Convert.ToString(P.VendorNum)).Select(P => new{P.Name}).FirstOrDefault();
if (partData != null)
{
tt[“ShortChar09”] = partData.Name;
}
}

@Adrian There are a couple of ways to get past this error. Convert before the Linq statement or using Sqlfunctions in the linq statement. But I think there may be a cleaner way to do what you are trying. As @NateS asked where does the data sit? How does the baq fit into the data direct email alert? If that is the objective then what does the baq do?

I ran both of these on post processing of getlist so i could see the data in the baq.

foreach (var tt in ttResults) //.Where(tt => !tt.Unchanged()))
{
var partData = Db.Vendor.Where(P => tt.UD38_Company == P.Company && tt.UD38_Key2 == System.Data.Entity.SqlServer.SqlFunctions.StringConvert((double)P.VendorNum)).Select(P => new {P.Name}).FirstOrDefault();
if (partData != null)
{
tt.UD38_ShortChar09 = partData.Name;
}
}



foreach (var tt in ttResults) //.Where(tt => !tt.Unchanged()))
{

var vendorLookup = Convert.ToInt32(tt.UD38_Key2);

var partData = Db.Vendor.Where(P => tt.UD38_Company == P.Company && vendorLookup == P.VendorNum).Select(P => new{P.Name}).FirstOrDefault();
if (partData != null)
{
tt.UD38_ShortChar09 = partData.Name;
}
}



You need to fix up your Select(), when there is only one field to return you don’t need the new{}

change it to

var partData = Db.Vendor.Where(P => tt.UD38_Company == P.Company && vendorLookup == P.VendorNum).Select(P => P.Name).FirstOrDefault();
if (partData != null)
{
tt.UD38_ShortChar09 = partData;
}

Hi Greg,
Thanks for the tip and help, I tried your solution and I’m getting an error of " the name ttResults" does not exist in the current context". I’m sure I’m missing something that I’m just not seeing.

foreach (var tt in ttResults.Where(tt => !tt.Unchanged()))
{
var partData = Db.Vendor.Where(P => tt.UD38_Company == P.Company && tt.UD38_Key2 == System.Data.Entity.SqlServer.SqlFunctions.StringConvert((double)P.VendorNum)).Select(P => new {P.Name}).FirstOrDefault();
if (partData != null)
{
tt.UD38_ShortChar09 = partData.Name;
}
}

@Adrian The code goes in post processing getlist of the UBAQ not on a UD38 bpm. As @NateS asked what is the goal here? If it is to send an email with data collected from the PO and UD38 I don’t see the purpose of the UBAQ. all of that can be done in the data directive.

If the goal is to merge PO results with UD38 results you don’t need to enter the PONum then save then getlist. You can just have a parameter and get the UD38 data for all POs as they are returned.

So let’s go back to what are you trying to solve as opposed to what is my error.

Greg

Hi Greg,
So I have an UBAQ the user will enter the PO number( key1) and part number ( key2) only, once they hit refresh it will pull in the details for them. Then I have an email check box for the user will select and when they hit save it shoot out an email with all of data pulled from the from UBAQ. My issue since I’m using a UD38 table I need to copy the data from Vendor table, POdetail, and POHeader over to one of the many ShortChar fields available. The only solution I found so far is a Pre-process Method Directive. I have shared my BAQ for you to review. MissingIncorrectCert.baq (57.6 KB)

I was able to get the data from Part table to work just fine with the method directive BPM I posted earlier, the I ran into the exception error for POHeader and Vendor thus my dilemma. I have very limited C# experience so any guidance you can provide it would be much appreciated.

@Adrian I think this can all be done in the baq. Something a consultant showed me a decade ago was that in a UBAQ you can use post processing getlist to do almost anything.

I added a couple of routines, but without data can’t run it. Does the data already exist in UD38?

if it does then you don’t need the base update. If you are creating it on the update in a bpm then you could create the UD records in the getlist and use a parameter(s) to get the initial data.
Also the baq has PONum as key1 and it looks like you are wanting the Vendor Name which is going to need a join.

There is a custom action with the basics for sending an email.

If this looks like a route you want to take we can help you get this all wrapped into one baq.

Greg

image
MissingIncorrectCert2.baq (76.8 KB)

@gpayne I uploaded the sample baq that you provided and when I hit the get list button I encounter an error message. at the bottom of the it states there is a input sting not in correct format.

Inner Exception

Input string was not in a correct format.

BPM runtime caught an unexpected exception of ‘FormatException’ type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail

Description: BPM runtime caught an unexpected exception of ‘FormatException’ type.
See more info in the Inner Exception section of Exception Details.
Program: CommonLanguageRuntimeLibrary
Method: StringToNumber
Original Exception Type: FormatException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 2007 in file:line:column :0:0

Client Stack Trace

at Epicor.ServiceModel.Channels.ImplBase1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets) at Ice.Proxy.BO.DynamicQueryImpl.GetList(DynamicQueryDataSet queryDS, QueryExecutionDataSet executionParams, Int32 pageSize, Int32 absolutePage, Boolean& hasMorePage) at Ice.Adapters.DynamicQueryAdapter.<>c__DisplayClass35_0.<GetList>b__0(DataSet datasetToSend) at Ice.Adapters.DynamicQueryAdapter.ProcessUbaqMethod(String methodName, DataSet updatedDS, Func2 methodExecutor, Boolean refreshQueryResultsDataset)
at Ice.Adapters.DynamicQueryAdapter.GetList(DynamicQueryDataSet queryDS, QueryExecutionDataSet execParams, Int32 pageSize, Int32 absolutePage, Boolean& hasMorePage)
at Ice.UI.App.BAQDesignerEntry.BAQTransaction.TestCallListBckg()
at Ice.UI.App.BAQDesignerEntry.BAQTransaction.<>c__DisplayClass223_1.b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()

Inner Exception

Input string was not in a correct format.

@gpayne I should add that I’m trying to pull in the vendor name, the sample in your BAQ is pulling in part details which I have already.

@Adrian I don’t have your data, so I can only make examples. Look at the code below in postprocessing of getlist. I sent it disabled, so it would not be the cause of the error unless you enabled it without changing to fit your data. You see Key2 is the lookup for part and vendor name which is not going to work in a real situation.

/* get vendor AND PART data */


foreach (var tt in ttResults) //.Where(tt => !tt.Unchanged()))
{

  var vendorLookup = Convert.ToInt32(tt.UD38_Key2);
  
  var vendData = Db.Vendor.Where(P => tt.UD38_Company == P.Company && vendorLookup == P.VendorNum).Select(P => P.Name).FirstOrDefault();
  if (vendData != null)
  {
  tt.UD38_ShortChar09 = vendData;
  }
  
  var partData = Db.Part.Where(P => tt.UD38_Company == P.Company && tt.UD38_Key2 ==(P.PartNum)).Select(P => new{P.PartDescription, P.ProdCode}).FirstOrDefault();
  if (partData != null)
  {
  tt.UD38_ShortChar04 = partData.PartDescription;
  tt.UD38_ShortChar03 = partData.ProdCode;
  }
}

Thanks for everyone’s help , this was a simple example of me just over complicating and over thinking this project. I just simply updated the “Query to Object column mapping” tab to achieve what I needed. Dashboard is deployed and the users are happy.