Copy Company UD field to QuoteHed C#

I have a ud field added to the Company Table called QotTermsAndConditions_c.
I also added a UD field to the QuoteHed table called TermsAndConditions_c

I created a Method BPM on Quote.Update and added a preprocess BPM.

I tried to use the BO to create a dataset but I was getting an error that was pointing to some kind of address method that I was not using.

So I thought OK let me do this as a C#. However I am getting an error there as well. If anyone could spot my error I would greatly appreciate the help.

Here is the code I have now:

Erp.Tables.Company Company;

foreach(var ttQuoteHed_xRow in ttQuoteHed)
{
var ttQuoteHedRow=ttQuoteHed_xRow;
if(ttQuoteHed_xRow != null)
{
Company=(from Company_Row in Db.Company where Company_Row.Company==ttQuoteHedRow.Company select Company_Row).FirstOrDefault();
if(Company != null)
{
ttQuoteHedRow[“TermsAndConditions_c”] = Company[“QotTermsAndConditions_c”];
}

}

}

and when I try to save the code - I get an error message:
Server Side Exception

There is at least one compilation error.

Exception caught in: Epicor.ServiceModel

Error Detail

Description: There is at least one compilation error.
Details:
Error CS1593: Delegate ‘System.Func<Erp.Tables.Company,int,bool>’ does not take 1 arguments [Update.Pre.TermsAndConditio.cs(97,43)]
Error CS1660: Cannot convert lambda expression to type ‘string’ because it is not a delegate type [Update.Pre.TermsAndConditio.cs(97,43)]
Error CS1061: ‘Erp.Tables.Company’ does not contain a definition for ‘Company’ and no extension method ‘Company’ accepting a first argument of type ‘Erp.Tables.Company’ could be found (are you missing a using directive or an assembly reference?) [Update.Pre.TermsAndConditio.cs(97,61)]

I know there is something special about the Company table - I just don’t remember the specifics.

Thanks,

DaveO
Ph: 651-246-3281

I could be wrong, but shouldn’t you be testing your new var ttQuoteHedRow for not null?

foreach(var ttQuoteHed_xRow in ttQuoteHed)
{
var ttQuoteHedRow=ttQuoteHed_xRow;
if(ttQuoteHedRow != null)
}
Secondly, you may need to select the row before you set your var ttQuoteHedRow like so:

foreach(var ttQuoteHed_iterator in (from ttQuoteHed_xRow in ttQuoteHed
select ttQuoteHed_xRow))
{
QuoteHedRow=ttQuoteHed_iterator;
if(QuoteHedRow != null)
}

Additionally, I’ve always defined my rows for temp tables like so:
Erp.Tablesets.QuoteHedRow QuoteHedRow;
OR
Erp.Bpm.TempTables.QuoteHedTempRow QuoteHedRow;

It seems to depend on the BPM which one should be used. Hope that helps a little.

I took a look at this and when I added Company_Row and then typed the period it offered a drop down list of fields and I did not see Company but instead saw Company1.

I have taken this no further but you might want to try that change to get past the syntax error to see what happens.

where Company_Row.Company1==ttQuoteHedRow.Company

1 Like

Mr. Stephen: Thank you for the Heads up. I will give that a try.

DaveO

Mr. Stephan: You are the MAN.

That was my problem.

Thank you so much. :slight_smile:

DaveO