Looking for custom code for Method Directive

I was wondering if someone could help me with a custom code for users when they are putting and order on for 3 specific customer ID’s and the PickList/Job Comments box is blank to remind them to enter in the customer specific lot numbers so they will print on the job traveler.

I was hoping to use a code I have for part entry and reverse engineer it, but there’s references in there to fields and actions I’m not familiar with, so I don’t know what to change them to for this specific scenario.

I don’t know enough about how to compile these codes either to start from scratch myself. :frowning:

Any help is appreciated

Do you need custom code? Seems like it would just be a condition of if any of the 3 customer IDs and comments box is blank, then show warning message.

I would prefer to do it as a condition, but I don’t know how to write that condition to apply to more than one customer ID. Every time I try to put in an OR it says the syntax is bad.

The only conditions I have written in the past have been single liners with only one variable, and a prompt… so multiple lines and conditions is beyond what I know how to do. :frowning:

Can you share a screenshot of your condition with the OR?

This is how I was trying to set it up, probably completely wrong.

Oh just put in one custnum, then click the new button (Page icon above and to the left of the condition), and it will add a second row to the condition. Just have one for each, kind of like BAQ Criteria.


I definitely agree with @jgreenaway that you should just do it with widgets, but if you really want the custom code, this will do it:

var YourCustNums = new List<int> { 4632, 4458, 6062 };

bool CustMatchNoComment = ds.OrderDtl.Any( x => (x.Added() || x.Updated()) && YourCustNums.Contains(x.CustNum) && x.PickListComment.Length == 0 );

if ( CustMatchNoComment )
	string WarningMessage = "Please add the customer-specific Lot Number in PickList Comment";

	this.PublishInfoMessage( WarningMessage, 
					"Warning", "Warning" );

God I feel like a newb… This seem right?


Very close, but you’ll want to put an Open parenthesis in the first row “Prefix” column, and a close in the third row “Postfix” column.


Only issue now is I put that on the SalesOrder Method directive and It hits me with the prompt while saving the header since there are no lines or comments yet. It changed from my first screenshot, the Comment field I need to monitor is line based and not header.

I tried putting this on the SalesOrdHedDtl.Update method, but that doesn’t appear to be triggered when saving the order with a new line since the prompt does not come up.

Ah got it. Try changing the last row of your condition from null to string.Empty. If that doesn’t do it, you may have to add another condition.

Oh also change the conditions above it to use ttOrderDtl.CustNum instead of ttOrderHed.CustNum

Thank you! Got it working. Still had to leave it on the SalesOrder.Update Method, but as you noted I changed all of the fields to be pointing to a OrderDtl field verses OrderHed, and used the string.empty, not sure if that mattered but I still changed it.


The string.Empty, I think, would matter a lot. Since an empty string is not equivalent to a null in C#, I don’t think it would have ever showed your message if null is the criteria there. The reason that was showing the message when you were creating an order was that it was finding the custnum on the OrderHed, then looking for a ttOrderDtl.PickListComment, finding no ttOrderDtl Row at all, therefor that field was null.

@FTI-SeniorAdmin - one additional thought: right now, if you (or someone else) need to change which customers this applies to, you will need to go into the BAQ and change the condition criteria. Not something you want everyone to be able to do.

When I’ve done this sort of thing for clients, I’ll create a UD checkbox on the customer record and my condition in the BAQ is: if field “checkbox” = 1, raise warning message. This way future-proofs the BAQ and lets you hand off the maintenance of which customer orders get the warning to the Sales or Customer Service department.


This is a good plan! I was going to suggest a user code but this is better

That is a good idea, but I hate having to add check boxes to forms and modify the views so they can see them… it’s a 6 of one half dozen of another scenario the way I see it, since moving up in Epicor revisions will sometimes require re-design and recreating the forms to see said UD checkbox.

We have quite a few of these conditional prompts for various things so one more isn’t gonna be an issue. I’m also the highest power user when it comes to running BAQ’s, building dashboards, adding stuff like this or modifying it, and so on… There’s only one other super admin and he still comes to me to run an existing BAQ when he wants data. Maybe someday we’ll hire someone/people who understand and respect this system and want to use it to it’s fullest.

It does… I tested it with the currently working condition and it stopped working… :wink:

Can you do it as a systag on the customer record, and avoid needing to create another UD field?