Client context in BPM / Printing woes

I have an issue where I need to default printing based on what pc I am running from. I looked into using workstations but I found that to be bulky and messy, not to mention icouldnt find a way to default workstation based on the pc. I got the idea to simply create a text file on each local machine with the desired label printer. Problem is, in the partran BPM my c# code to read file fires on the server! Is there a way to change that context to the client? Should I find a way to read that file in a customization and pass it to BPM context? What are your suggestions for the best way to tackle this?

Thanks, Chris

How about tying it to a user? Custom Field in User and have that be pulled from callContext.DcdUserID? Most users are tied to a single workstation (though that isn’t always the case)

Though you should go the workstation route and assign the workstation to the user in User Maintenance that should default it

It could work but the biggest concern there is that there are at least 8 stations (that share 4 printers) and the users can be at any station. Maybe I am looking at this wrong though - is the DcdUserID the Epicor User or the Employee (in MES)? If it is the Logged-in Epicor user, that may work as we can set the stations to use a dedicated (login) account for that PC. Could you clarify that? If I am on the right track, next I will need some assistance with autologin - I attempted to put my user/pass into my sysconfig. but it did not log me in.

Also, I would like to mention I am doing printing in strange fashion - we use Bartender/Commander for printing labels and we tried the Report Style/Report Data Def route but it had a few flaws. The most problematic was that I couldn’t find a way to add BPM context fields to the data def - this was important because I was using UDCodes to autoinc a number for boxcount which I couldnt get to the label. My solution was probably overboard - I deleted the AUTOPRINT object in BMP and completely wrote my own print file in C#, which works great. The issue moving forward is that I have to understand how to query/link User -> Workstation -> Device -> PrinterName to pass to my file.

It is the Epicor logged in ID

You are not doing anything “weird” most of us that user bartender use it the way you do. The epicor / bartender relationship is spotty at best :slight_smile:

User you can get form the call context (and maybe even workstation) then just query the WorkStation data from the WorkStation table

1 Like

Thanks for your help Jose.

That’s great to hear that I am not wandering too far off the accepted path. It seems to me that my code running in the BPM is sooo slow - most likely due to all the querying and linking of tables.

Could someone verify I am attacking the tables/linking in an acceptable fashion?

Here is my code (note the use of ReadUncommitted/NOLOCK - is it needed?)

using (var txn = new TransactionScope(
new TransactionOptions
IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted

            var joinResultRows = from pTransRow in ttPartTran
                                 join pRow in Db.Part
                                 on new { pTransRow.Company, pTransRow.PartNum }   //link these
                                 equals new { pRow.Company, pRow.PartNum } into PARTS  // to these

                                  from P in PARTS
                                 join pmRow in Db.PartMtl
                                 on new         { P.Company, x1 = P.PartNum,  }   //link these
                                 equals new { pmRow.Company, x1 = pmRow.PartNum }   // to these 
                                 select new { PartNum = pTransRow.PartNum,  TranQty = pTransRow.TranQty, TranType = pTransRow.TranType, Mat = pmRow.MtlPartNum, UOMCode = pmRow.UOMCode, pTransRow.TranDate, e = pTransRow.EmpID, pTransRow.JobNum, pTransRow.RevisionNum, dev = P.UserChar4, dexexp = P.UserDate4, label = P.UserChar3, PPC = P.PartsPerContainer};


var PP = (from PartsRow in Db.Part.With(LockHint.NoLock) where
PartsRow.PartNum == joinResult.Mat
select PartsRow).FirstOrDefault();

You don’t need Transactionscope or Isolation Level the framework and the Epicor Wrap Arounds take care of that for you and you can end up doing duplicate Scope

But your join looks good, maybe a little clunky but it works. Depending on what you are doing it may behoove you to work in a pattern like this. However there is nothing wrong with how you are doing things.

foreach(x in ttTable.Where(x,y,z))
 //use x to join / lookup / etc other tables / parts
  var mything = (from z in Db.Table where z.Xvalue == x.Value ....etc);

Keep in mind that the ttTables and Db.XX are in different contexts the TTables are POCO’s in memory while Db.XX are DB Context so joining them can sometimes cause performance issues if not done correctly.

Wow, the code snippet looks so simple yet elegant! Could you perhaps detail its implementation a little (maybe a small, simple example)? My use of the Isolation Level was to force a NOLOCK as I had read somewhere that it could cause performance issues otherwise - I get the impression this isn’t your first rodeo so I will take you suggestion to heart and remove it.

Here’s some examples from the presentation that @rbucek and I did last year at Epicor insights. The Top example is BPM code which is similar pattern

What an amazing resource! What are the dates for the next event you will be holding like this? What are the pre-reqs/costs? I am all in!

Before I even got to the code sample I saw your remark about debugging in VS - I was just complaining about that.

Super stoked - Thanks again!

This was a presentation we did for Epicor Insights Epicor Insights 2023 Conference | Epicor U.S. you may find more information there. I believe the next one is May.

Also - do you do on-site consulting? I’ll give a small bit of background on my current situation - I have been using Epicor (or any ERP) for only 3 months - I am at a new job. The issue is my company has been ‘attempting’ to implement this system for 3 years!!! It still isn’t in place. I’ve come in with a technical background and feel like I am making amazing headway in such short time but without having a deep knowledge of the foundation of the system, I am not moving as fast as I would like. Not to mention I am fighting an uphill battle internally… Some of the biggest things we hope to accomplish are menial yet require someone who knows exactly how the system works. We are talking getting barcoding on all processes, heavy MES usage for EVERYTHING on the shop floor, and lot’s of company specific quirks.

My company has extensively used Epicor consultants but not of the right caliber - I spent the last 2 weeks trying to work with 2 consultants who were more 'TOP LEVEL" guys who just offered up very generic solutions with no details.

If this is up your alley definitely drop me a line and we can work out the specifics.

Hi Chris,
Yes, message me offline and we’ll discuss.