Auto increment a UD field on LaborDtl

Good Morning Everyone

I will start with noting that I know there are multiple post on Auto Incrementing…usually seems to be customer ID and Project ID related, and I have tried a lot of the different suggestions I have found…but can’t seem to get anything working…which i am sure is down to my lack of execution of the suggestions…but alas, I am bashing my head against the wall and humbly asking for a kick in the right direction (be gentle!)

I have a UD checkbox, on the Labordtl table, that when checked “true” I want to autofill another UD field (integer) with a tracking number (that I want to sequentially fill based on the previous tracking number created). This all takes place when the user, in MES, is ending an activity.

I have tried using the UD Codes option (Auto Numbering - Customer ID - #23 by timshuwy), placing the custom code on the Erp.LaborDtl.Update method (post-processing), but nothing seems to fire…I have also tried the “Ice.Lib.NextValue(Db).GetNextSequence” option (Auto Sequence Customer ID - #9 by josecgomez), but always get an error saying that the entry doesn’t exist. When I try to add ice.Lib.Nextvalue to the Assembly References its not even an option for me to select?

Again I am sure its in my execution, but you fine people always seem to have a solution that saves me from the method madness in Epicor… (running version 10.1.500.9).

Thanks!

So first, let’s break this problem down into smaller chunks.

Did you find a suitable spot to get the BPM to fire? If you say it doesn’t fire at all, it’s not going to matter what code you put where. You can place some message boxes in the BPM to check and see what stuff if firing where. Once you are fairly certain you have a viable spot to put your BPM, then we can move onto the next part.

1 Like

Ok that seems like a good place to start…as when I put a standard BPM on the post processing or pre processing (to show a message box) it doesn’t show in either case…so I guess that isn’t the right method…I have tried to do a trace on MES in the past but I don’t see to get anything in the log…?

Message boxes should work on the MES screen. You can do a trace in MES as well. You can do a trace in MES, right click on some gray space and it should show up here.

@adamk,
i have done many developments around this area i can share it with you, and as @Banderson said, BPM is your easiest choice, but you need to find your trigger first, then lay down your logic between DB tables and ttRecords to decide if you can achieve it by using the widget straight away or you need to code it.

A BPM on the LaborDtl table? Am i going down the wrong path looking at Method directives?

Can’t believe I didn’t know that was there…rookie move…

Ok so I have the tracing…but there is A LOT of junk coming back. I have closed the system monitor, just trying to comb through what was returned

1 Like

method directive is correct, but you need to decide which one, my best guess is that Start Activity

Method and data directives are two different tools that many times can accomplish the same things.

Method directives will catch everything using that specific method. Other screens may use the same method, but it might use a different one, so it’s possible that something may make it to the table without hitting your BPM. That shouldn’t deter you from using them, just something to think about. Since methods often hit more than one table at a time, you will have access to all of the temporary tables that method is hitting. This can be super useful if your decision/criteria is complicated and you need to see more things to help the BPM to decide what to do.

Data directives will catch anything that touches that table no matter what. However, they are more blind to what or where that table is being touched, they only see (without custom code) what’s in that specific table. Also, the BPM will have to be run every time the table is touched, so they could be a performance problem.

For your specific case, if you are looking at hitting the labordtl table and you are doing something that is housed solely within that table, I would start with an in-transaction data directive. It’s probably going to be easier to get working consistently than a method directive.

1 Like

@Banderson,
i would say method directive in this case has more control as he specify that he need to capture this at MES activity

He has a checkbox and a single field, all on the same table. Why does he need more control?

for this specific reason, i think it is better to trigger this task ONLY when Start Activity, plus i found method directive more consistent than the data -if the relevant trigger been selected- not the other way around, but this is only me i could be wrong

I have had success in getting a data directive working, but I can’t get the auto increment portion…all of the auto incrementing suggestions I found pointed down the method directives path which is why I ended up that way…With a data directive, I can get the field, to be filled, when the checkbox is changed to True…but I can’t see to get the auto populate/incremental function happening for the other field…

1 Like

is it possible to share your work and/or results, so people can see what you are doing and advice

1 Like

So I got it working in a Data directive on a UD table, so I know it works. We just have to figure out what you’re missing.

Yes sorry about that. I have tried and deleted so many things I don’t have a full account

Long story short I placed the following on the Erp.LaborDtl.Update

but after doing some testing (thanks to @Banderson for the suggestion) it doesn’t seem to be the right method as when I placed a basic message box direction to fire nothing happened. The custom code was based on using UD Codes

In a data directive on the Labordtl table, I have it working great…I can populate the field, when the checkbox is changed, but I don’t know how to get the number to be auto populated and increment based on the last number used

Since I tried the data directive thing, here is what I did. Is that what you tried?

no one said it won’t, i simply said it is better to control the trigger at the Start Activity only, anyway it is time to go home if the issue still not solved by tomorrow then i will try to do it my way and share the results

pre-processing Method directive is going to be the exact same setup, exact same reference added. I just tried it out, it works the same.

@adamk, post processing isn’t going to work for the update method, because the value is already written to the table at that point, you will need to do pre-processing.

One more note of clarification that I just figured out. The string that you put after GetNextSequence is whatever you want it to be. It’s not the field as I originally was assuming.

new Ice.Lib.NextValue(Db).GetNextSequence("Charatcter10").ToString("1000")

I see that my fat fingered field name worked fine.

2 Likes

Ok I will try to reproduce now…It looks like exactly what I need (but not a way that I have tried it up to this point). I know that all of the suggestions I found, that referenced using the ice.lib.nextvalue didn’t work as I could not find that as a option under the reference tab (the only ice.lib that was an option was ice.lib.soultiontracker… Do I need to add the nextvalue somehow?

1 Like