Error Handling message - NAV 5.0

Hi,

I was wondering how to customize an error message for a particualr error in NAV 5.0. For example:

Table = Brand-Gender Setup

Field = Gender

Table Relation = “Brand-Gender Setup”.Gender WHERE (Brand=FIELD(Brand Code))

I am using this to validate that a particular Gender Type (MALE,FEMALE,BOY GIRL,UNISEX) is valid for a particular BRAND only. Everything is working fine, but my problem is I want to customize the message that appears when a wrong input is entered.

Right now the error showing is:

The Brand-Gender Setup does not exist.

Identification fields and values:

Brand=, Gender=

and instead I want to show something simple like, “Invalid input.” [:D]

Is this possible? How? Thanks.

How about adding MALE;FEMALE;BOY;GIRL;UNISEX

in the ValuesAllowed property?

http://msdn.microsoft.com/en-us/library/dd355049.aspx

2388.vap.JPG

Hi,

Thanks for the reply but that did not answer my question. :slight_smile:

I was looking for a way to customize the error message itself, but granted the example may not be very good as I can simply put the gender as an option or like you said in the ValuesAllowed property.

Let’s say that the table relation is for a brand list containing 200 records, so an option field or a ValuesAllowed property will not be applicable, so the same problem if the user enters a wrong “brand” the standard error appears.

How can I capture the error and modify the ERROR MESSAGE to not display the standard NAV error.

Thanks for any input.

Hi,

Do you want to show only applicable values based on selected brand in look up screen ? or do you want to show your own error message when wrong value selected ?

Hi Marshal, not necessarily the applicable values as the wrong input might just be a typo but I definitely want to customize the error when there is a wrong input.

A typo error produces a convoluted error message like for example,

"There is no dimension value within the filter. Filters: Code: , Global DImension No.: "

can be simplified to just “Invalid input”.

Hi

Do you have any table which hold data in combination of Brand and Gender as like below

so that you can easily write code oNValidate() trigger to filter Selected brand and selected Gender if value not found then you can throw your own error message.

Thanks

Jerome Marshal. J

8662.Brand & Gender Combination.JPG

Marshal, I do have a that exactly similar setup on the table.

Having the same table, if a user selects BRAND1 in a form and then selects GIRLS on the same form, i get the error mentioned in my previous post.

I actually already tried putting ERROR(‘INVALID INPUT’) in the following

  • ONVALIDATE of the form field for gender
  • ONVALIDATE of the gender field of the SOURCETABLE of the form

but to no avail, I still get the default error.

Hi Try this

  • Do not writ any code in Form controls OnValidate()
  • Comment all the code in OnValidate() Form Field
  • go to the table field Gender - OnValidate() - and write below code

i hope in the setup table Brand,Gender both combination should be primary key then, create a record variable for setup table ex (BrndGenSetu)

if not BrndGenSetu.Get(Rec.brandCode,Rec.GenderCode) then

Error(‘Invalid Input’);

write the above code as very first line in OnValidate() of gender field (table field not in form field)