BPM Help

,

I am trying to make a BPM that will show an error message when a user enters a job for a part with no standard cost. The only way I’ve found so far is to make it on the JobAssembly table and check the TLE value of the job on pre-processing. However, when I enable the BPM it does not go off. Has anyone done this before or know of a better way of accomplishing this?

When do you want it to trigger?
Turn on Tracing and see what methods Epicor Calls when this happens
Hang BPM On Pre-Processing of Said Method

1 Like

@josecgomez,

I would like it to trigger whenever a job is entered and its part has no standard cost. How do I turn on tracing and would it be available to me seeing as we are in gov cloud? I assumed that it would happen on the JobEntry method under update but I could be wrong.

I ran a trace and two BO methods are fired directly after tabbing out of the PartNum field (on a newly created job)
JobEntry.CheckPrePartInfo and JobEntry.ChangeJobHeadPartNum

You probably want to use the second one as that fires on the first time a part is entered, or when an existing job has it’s P/N changed.

1 Like

@ckrusen,

Im still not getting the desired outcome. I believe it may be because of the fields that I am using.

I have the TLE fields, which are calculated based on the standard cost of the parts, selected because the part cost table is not used within the JobEntry method. Am I looking at this the wrong way? Thanks for the help!

The Job Assembly table isn’t going to really be touched at this point.
As I sugested before run a trace, you’ll be able to see which tables are touched and available for each of the calls.
JobHead is likely the only one with data at this point. Use that to lookup the Part

A I didn’t see your message about how to turn on Tracing. I’m not familiar with gov cloud but I’m guessing is just a more “bureaucratic” public cloud offering (@Mark_Wonsil :yum: )

So the standard tracing mechanism should work.
See Ice Tool Guide
Pages 889 - 896

But the short of it is in your Settings there is a Tracing Options Program which you can enable to see the different methods and calls that Epicor Makes (including the data sent, received and changed)

I highly recommend you get familiar with this tool since it is your life line in most situations.

image

image

2 Likes

You can create a variable and set it with a Set Arg/Variable widget. You fetch the StdCost in the expression like:

image

with the expression:

Db.PartCost.Where( r =>r.Company == callContextClient.CurrentCompany && r.PartNum == ttJobHeadRow.PartNum).Select( r =>r.StdMaterialCost).DefaultIfEmpty(0).FirstOrDefault()

You might need to make it the sum of the various PartCost fields related to Std cost

Db.PartCost.Where( r =>r.Company == callContextClient.CurrentCompany && r.PartNum == ttJobHeadRow.PartNum).Select( r =>r.StdMaterialCost).DefaultIfEmpty(0).FirstOrDefault()
+ Db.PartCost.Where( r =>r.Company == callContextClient.CurrentCompany && r.PartNum == ttJobHeadRow.PartNum).Select( r =>r.StdLaborCost).DefaultIfEmpty(0).FirstOrDefault()
+ Db.PartCost.Where( r =>r.Company == callContextClient.CurrentCompany && r.PartNum == ttJobHeadRow.PartNum).Select( r =>r.StdBurdenCost).DefaultIfEmpty(0).FirstOrDefault()
+ ... and for StdSubContCost 
+ ... and for StdMtlBurCost

The have your condition use that variable to see if it is <= 0

1 Like

I wish there was a way to mark you both as the solution! @ckrusen your code worked flawlessly and answered my questions on how much custom code can be done within the BPM. @josecgomez I will be using the Trace from now on. The document it spits out will help with tons of other troubleshooting things I have to do. Thank you both so much!

One last question. Are these global variables once they are in place or do I have to build these for all of my sub companies?

1 Like

If the BPM is marked as Cross Company it should work across all companies.

1 Like

FYI… if doing a lookup in the PartCost table, you should also include the Cost ID for the site you are in… Many people default this to “1” since that is how Epicor is delivered, but it is very easy and possible to create a new CostID, and point your site to this new Cost ID, and then your BPM would not function properly.

2 Likes