-1

I have the following code for a BPM (Business Process Management) Workflow Designer in Pre-processing for Epicor ERP System.

using Ice.Memo;
foreach (var ttJobHead_xRow in (from ttJobHead_Row in ttJobHead where 
ttJobHead_Row.RowMod == IceRow.ROWSTATE_UPDATED select ttJobHead_Row))
{
     var Memo_Row = (from IM in Db.Ice.Memo where IM.Key1 == ttJobHead_xRow.PartNum select IM);
     if (Memo_Row != null)
     {
        callContextBpmData.ShortChar04 = ttJobHead_xRow.MemoText.ToString();
        callContextBpmData.ShortChar05 = ttJobHead_xRow.MemoDesc.ToString();
     }
}

The goal of this code is to have a condition based on when a row in the table, JobHead, has been updated. And then to in a sense tie together two tables (ttJobHead and Memo). And later in the if statement, assign a shortchar to certain fields for later input into an email.

When compiling I am getting the following two errors:

Error CS1003: Syntax error, '(' expected [Update.Pre.New_Job_with_Par.cs(86,19)]

Error CS1026: ) expected [Update.Pre.New_Job_with_Par.cs(86,27)]

Whats going wrong? Also, is there a better way to accomplish this?

Community
  • 1
  • 1
Joe B
  • 1
  • 5
    This code doesn't look like its in a class, let alone a method. –  Aug 07 '18 at 15:09
  • 1
    Side note: `Memo_Row` will never be null. You should be getting a compiler warning saying the condition is always false. – itsme86 Aug 07 '18 at 15:10
  • You might also want to assign the result of your first LINQ expression to a temporary variable to improve readability – Misamoto Aug 07 '18 at 15:15
  • You seem to be overusing LINQ in query form when direct calls to `.Where` would do. A query of the form `from x in c where p select x` can simply be written `c.Where(x => p)` (or even `c.Single(x => p)` if you're specifically expecting one result and want to get it directly). Using the query form as a oneliner tends to lose out on readability, especially when combined with `foreach`. – Jeroen Mostert Aug 07 '18 at 15:18
  • Help us out - those numbers in brackets refer to (line no, column) values. Since your code in your question doesn't have 86 lines, please tell us *which line this is actually telling you about*. – Damien_The_Unbeliever Aug 07 '18 at 15:20
  • I have an added a class and a method now. Thank you. And as for the line numbers, I can't tell you more about it. In Epicor you have to write any custom code in their designated custom code window. It's compiling elsewhere, I assume with more lines than what I have entered, giving me a total misread on where the actual error is. That's why I have come to Stack Overflow because I can't even find the location of the errors. – Joe B Aug 07 '18 at 15:25
  • Also, after adding a class and method, the compiler no longer produced CS1003 and CS1026, but now produces CS1513 and CS1022. – Joe B Aug 07 '18 at 15:27
  • Update the code in the question. It's hard to help with what we can't see. –  Aug 07 '18 at 17:43

1 Answers1

0

Assuming you're using Epicor 10 and creating an action for JobEntry.Update.

You can't have the using statement directly in the BPM, I'm pretty sure that's your issue, you need to add by clicking the "Usings & References" on the "Enter Custom Code" form.

My guess is that it's wanting a using statement, not directive, and this needs parens.

using(MyDisposable d = new MyDisposable())
{
    ...
}

Having said that, if you go to your server, you should be able to see your BPM source code (e.g. c:\inetpub\wwwroot\E10_Test\Server\BPM\Sources\BO\JobEntry.Update). This will help you in debugging because the line numbers line up with this source code.

Garrett
  • 11
  • 3