10.2.200.6 "Order Entry - Raise Exception for custom tab's UD field"

With being tasked to create a custom tab under “Order Entry>>Lines>>New Tab”. There is a new UD field within the tab, in which end users can enter an original part number for no charges. I want to raise an exception that stops users from entering a part that’s not currently in the database but also allow an empty value. With that being said I proceeded with the following:

  1. Open Method Directives
  2. Search for “Sales Order” business object
  3. Selected method “Update”
  4. Created new “Pre-Processing”
  5. Created condition block with the following:
  6. Raised Exception with message

Condition 1 = Number of Rows in the query (ttOrderDtl.Company = Erp.Part.Company and ttOrderDtl.Orig_Part_Purch_c = ERP.Part.PartNum) is equal to “1”

Condition 2 = The ttOrderDtl.Orig_Part_Purch_c field of the added row is equal to the " " expression

Condition 3 = The ttOrderDtl.Orig_Part_Purch_c field of the changed row is equal to the " " expression

Condition 4 = The ttOrderDtl.Orig_Part_Purch_c field of the updated row is equal to the " " expression

Now all scenarios below pass except for one:

Scenarios that pass:
-User selects existing order and navigates to new tab and in “Orig_Part_Purch_c” field the user enters a valid part number (No message is presented) user clicks save.

-User selects existing order and navigates to new tab and in “Orig_Part_Purch_c” field the user enters a non valid part number and clicks save (Message is presented of invalid part number)

-User selects existing order and navigates to new tab and in “Orig_Part_Purch_c” field the user enters no part number and clicks save (No message is presented)

-User creates a new order and lines but with no information added to the new tab. (No message is presented)

Scenarios that fail:
-User selects existing order and navigates to new tab and in “Orig_Part_Purch_c” field the user enters a valid part number. Clicks save and in the same session realizes they entered a wrong valid part number and proceeds to delete and enter a new one but its an invalid part number. (Message should appear but doesn’t)

Is data only going to be entered from the UI into this field? One way is to perform a data validation on a field event for that custom field such as if you’re able to return any data from a GetByID on the part num they entered, proceed with allowing the user to save otherwise clear the field and throw an exception to the user.

Are you filtering your rows by the row mod in the first part of the condition? Sometimes there are two rows, one with a row mod, and one without (the existing one). That will mess up your query tests if you don’t filter out for that.

Do you know how to make a message box for testing and showing the tt rows? That will help you debug that stuff.

@Aaron_Moreng Data is only being entered through the UI. Regarding custom code for this. I referenced several posts and a few online source for understanding the concept of adding in the row mod reference and the exception message. But the part I have been stuck on is creating conditions in C# similar to what’s in the UI. (I just need to study more on C#, all my time goes to SQL and reports)

@Banderson Do you mean adding a table criteria to “ttorderdtl” in reference like so:

image

And i’m not that savvy when it comes to C#. Could you provide an example please?

edit, yes. (sorry if you saw the other stuff, your screen shot didn’t have all of the stuff so I got confused)

I would probably do a not null or exist, or not empty string. I would have to experiment to see which one works. But if your list works, that should be ok too.

1 Like

check out this post for the message box. It’s not C#

When I say UI I am referring to the user interface on the actual Order Entry form, not the BPM widgets (just in case that wasn’t clear). If you plan on accomplishing this task through a form customization, there are a few ways to do this. Can you distill the actual requirement down to its essentials parts? As I understand it, you are asking for an exception to be raised if the custom field value is not a valid part but it will allow no value at all. Is that correct?

@Aaron_Moreng Sorry for the confusion, I understood what you meant. Yes, end users will be entering the data from the Order Entry form on a new tab with the new UD field. I was referring to custom code as well as trying out the Method Directives built in functions to come up with ideas on how to tackle the requirement. (As C# is something I want to be more involved with) And yes the requirement is to validate the new UD field’s data entry as to whether its a valid part or not within the system (with the exception of it being empty as users will generate new orders and not fill out the form/UD field every time as its for no charge requirements)

Perhaps you already know, but there are 3 basic entities that you can use to accomplish these kinds of tasks. Form customization, Data Directives (database update monitoring), and Method Directives (monitors before or after a business object method fires). Both data and method directive act server side, so this has some distinct advantages in certain scenarios. BPMs are also much easier to maintain/deploy in most scenarios. I think this particular case could be solved very easily with a Data Directive because you are monitoring a bound field’s value changing.
I have an example of a data directive I use to monitor the field value of the OrderHed.PONum field.
This one is a n-transaction directive, meaning that it’s not been saved to the database yet and gives us an opportunity to intercept the data if needed.

In my conditional block, I have two things it’s checking. The first is that the PONum field changed from any to another (which also works for you, since by default your field will be empty and this condition will only be checked if the field changes to something else) and that the number of rows in a custom query is not less than one (I’ll explain in a second).


My queryinner joins the ttOrderHed table with Erp.CustAttr in this case, but you would join it to your Part table on the appropriate fields.

You would want to join on Company to Company and OrderHed_YourCustomField_c to PartNum. If there is a valid value in the YourCustomField_c field, then an inner join will be possible and should return at least one row.You would also want to change the “is not less than” to “is less than 1” if you plan on triggering the condition.
If there is not a valid value in that field, then no rows will be returned from the query. If this is the case, you will positively fail the conditional check and you should then attach an exception box from the TRUE side of the conditional check.

Give that a shot and let me know if it didn’t work

2 Likes

Thanks @Aaron_Moreng for the input. I created the data directive per your notes and it achieves the same outcome regarding my previously posted scenarios where only one fails out of the five test cases.

Scenario that fails:
-User selects existing order and navigates to new tab and in “Orig_Part_Purch_c” field the user enters a valid part number. Clicks save and in the same session realizes they entered a wrong (But valid part number) and proceeds to delete and enter a new one but its an invalid part number. (Message should appear but doesn’t and a invalid value is added to the database)

So the user can enters a valid part and saves, so the part num is stored in that field. The user then decides to update the field to a new invalid value. Can I see your BPM?

No_Charge_Valid_Customer Solution_3.2.200.0.zip (32.5 KB)

Here are the steps:

  1. User navigates to Order Entry
  2. Search for order 10277
  3. User navigates to “Lines>>No Charge Tab”
  4. In the “No Charge Tab” user click on “Orig_Part_Purch_c” and enters in part “1234”
  5. User clicks save
  6. User realizes part “1234” was the wrong part number (but it was valid for the system to accept)
  7. User clears field of “1234” and puts in part “12345” (which is invalid) but the system accepts it.

Sorry I meant screenshots :slight_smile:

You query should only look at the record with ttOrderDtl.RowMod != “”.
Also, you only need the “changed row” condition. This covers “Added” and “updated”.

1 Like

Thanks for the help everyone. After reviewing the original method directive I created and updating it to meet the specs of “RowMod” and only using “Changed” the directive passes all my test cases.
image

This one did helped me out in one of my UD field check. Thanks aaron.