Force PartNum to upper case (again)

OK I have looked at all of the topics on how to do this and can’t get it to work. As the title says, I want to make sure the part number is upper case. So, from reading, it sounds like there are multiple ways to do this:

  1. Form event - Part_BeforeFieldChange

  2. Data directive - In-Transaction directive on the Part table

  3. Method directive - Pre-Processing directive on Erp.Part.ChangePartNum

It seems like method #3 above is the preferred way of doing this (from here so that is what I am trying. So I created a Pre-Processing directive on the Erp.Part.ChangePartNum and entered the designer and added a ‘Set Field’ widget. I set it to this:

'Set the ttPart.PartNum field of the updated row to the expression: BpmFunc.ToUpper(ttPartRow.PartNum)

And… it doesn’t work. I validated, saved, and closed Epicor and it does not work on the Part form. What am I missing?

thanks

Maybe a little clarification on my goal. The goal is to make sure the Part Number is in upper case for all new parts.

#2 works for ALL parts no matter what object creates them.

6 Likes

Another vote for no.2 method here, which is what we use to do exactly this.

A couple of points - the thread you mention deals with screen customization, and if you’re wanting to force all NEW parts to upper case then you need to catch added rows rather than updated ones.

2 Likes

Another vote for #2. in-trans, added row, partnum.ToUpper(). If by chance you have some code generating part numbers on GetNew then put the ToUpper there.

1 Like

But does the change show in the UI? I think that may be the OP’s issue.

it does as soon as the save is made…

3 Likes

Please do not use BpmFunc those are helper methods created for writing ABLSharp( Aide those ABL users to transition, but the functions are usually implemented in pretty awful ways). Use the .net equivalent of that which is .ToUpper();

Set the ttPart.PartNum field of the changed row to the expression: ttPartRow.PartNum.ToUpper()

Also the reason it doesn’t work is likely cause you are using “updated row” you should change that to ChangedRow (Updated or Added)

3 Likes

Ugh - can’t get this to work! I did what you said.

Here is the workflow designer:

And here is the C# expression:
image

I checked syntax, validated it, saved, closed Epicor and restarted and does not seem to be working. It’s marked as ‘Enabled’.

Here is the Part screen after creating a new part, saving and refreshing:
image

Any ideas? thanks :slightly_smiling_face:

ChangePartNum takes in an input parameter apply it to the parameter instead of the ttPart

1 Like

I think you’re better off putting that on the data directive. Do an in transaction and set the field the same way on any added rows.

That method (ChangePartNum) is behaving oddly.

4 Likes

I wanted to keep going down one path as long as this way (method directive) is feasible. If I can’t get it to work I will try this. Thanks.

I’m not getting it… I tried this:
image

dsPartRow.PartNum.ToUpper()

and it is still not working.

(sorry this was meant as reply to @josecgomez )

Ok well I tried a data directive and it worked! Basically the same expression so not sure why it didn’t work in the method directive, but it sounds like this is maybe the better solution anyways. So here is what I did:

… and the expression:
image

Note that I used the default ‘BpmFunc’ version of the function since that is what was supplied. I didn’t try just the .Net ‘ToUpper’ so I don’t know if that would have worked also.

Anyways, when I enter or update a Part:
image

Then save it, it capitalizes the part number:
image

So I am happy. I think I will also perform this same task on the description as well.

Thanks to all that replied - it is much appreciated!
Jim

2 Likes

Your code worked in my test using Part.Update method directive.

On a new record in Part, add a code widget:

foreach(var row in ttPart)
  {
     
      row["PartNum"] = row["PartNum"].ToString().ToUpper();
      
  }

Pierre

1 Like

There is a fringe reason in Part Entry that the method directive did not work. In a lot of cases what you did should work fine, but Epicor does some goofy stuff with new parts and local variable stores in the form screen itself on Part Entry.

Or builds releases for the first line of a Purchase Order/Sales Order…

1 Like

It has to do with the Lookup vs New feature of that field. If you type some random SH*T into the partnum field Epicor does a lookup to see if it can find it and if it doesn’t it prompts you (new?)

That logic first temporarily holds on to the typed value in a local variable which they then put right back on the textbox regardless of what the method did… (Crappy logic if you ask me) but alas that’s why it didn’t work.

2 Likes

If anyone want’s to fart around with it the variable is oTrans.newPartNum they store the value there, then after GetNew is settled in they set tbPart.Text = oTrans.newPartNum it’s silly.

1 Like

So making a new part with part maintenance can be done two ways (actually 3, maybe more)

  1. With a cleared Part Maintenance form, type the desired Partnum into the field and hit tab. Like @josecgomez said, a lookup will occur to see if it exists. If it doesn’t, your prompted to make a new Part.
  2. In Part Maintenance form, select New -> Part.

Does the state of the ttPart record vary with which of the above you used? Do both call the same BO? (I assume #1 calls some extra BO’s based on the lookup and retrieval if a match is found)

The third way that came to mind was using Actions -> Duplicate Part.

Obviously a Data Directive would catch any of these. But if your required customization was more than just forcing the PartNum to UPPER case, you might need a Method Directive. Or more than one.