Coding Error.
Rajat_M
Member Posts: 34
Hello,
I have created two fields in the 'Item Card' page, i.e. Item Type & Item Color. Both are option fields.In Item Type field I declared three options:1.Paper, 2.Ink, 3.Chemical & in Item Color I declared 1.White & 2.Red options. I want to add some functionalities on those fields i.e. whenever a user selects 'Ink' option from the Item Type field it prompts the user to select at least one color from the Item Color field.If the user doesn't select any color then it'll show an error msg. I hv write the following code within the 'OnValidate' trigger of Item Type field:
if "Item Type"="Item Type"::Ink then
"Item Color":="Item Color"::Red,White
else
Errror('Please select a color');
But it shows syntax error. Please help me out.
I have created two fields in the 'Item Card' page, i.e. Item Type & Item Color. Both are option fields.In Item Type field I declared three options:1.Paper, 2.Ink, 3.Chemical & in Item Color I declared 1.White & 2.Red options. I want to add some functionalities on those fields i.e. whenever a user selects 'Ink' option from the Item Type field it prompts the user to select at least one color from the Item Color field.If the user doesn't select any color then it'll show an error msg. I hv write the following code within the 'OnValidate' trigger of Item Type field:
if "Item Type"="Item Type"::Ink then
"Item Color":="Item Color"::Red,White
else
Errror('Please select a color');
But it shows syntax error. Please help me out.
0
Best Answer
-
If I understand correctly you want to show something as prompt with two options to select.
Your code should look roughly like this:IF "Item Type" = "Item Type"::Ink THEN SelectedResult := STRMENU('Red,White',1,'Select color'); IF SelectedResult = 0 THEN ERROR('You have to select color'); "Item Color" := SelectedResult - 1;
And better use this code on the page, because if you use it on OnValidate on table, you can encounter situation when validating by code (not by user) will throw you big error about transaction
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.1
Answers
-
Syntax error is in this line
"Item Color":="Item Color"::Red,White
But I didn't understand why you are writing code in Item Type Onvalidate.
It will execute immediately after user selecting Ink in Item Type.
Probably you should show a message that Please select colour etc. if item type is Ink.
You can use Blocked field here to make some fields mandatory
1. On Item Type validate set Blocked field to Yes
2. On Item Color field validate set it to no
3. If user tries to make blocked field then check whether user has entered Item Colour and if not show error.0 -
If I understand correctly you want to show something as prompt with two options to select.
Your code should look roughly like this:IF "Item Type" = "Item Type"::Ink THEN SelectedResult := STRMENU('Red,White',1,'Select color'); IF SelectedResult = 0 THEN ERROR('You have to select color'); "Item Color" := SelectedResult - 1;
And better use this code on the page, because if you use it on OnValidate on table, you can encounter situation when validating by code (not by user) will throw you big error about transaction
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.1 -
If I understand correctly you want to show something as prompt with two options to select.
Your code should look roughly like this:IF "Item Type" = "Item Type"::Ink THEN SelectedResult := STRMENU('Red,White',1,'Select color'); IF SelectedResult = 0 THEN ERROR('You have to select color'); "Item Color" := SelectedResult - 1;
And better use this code on the page, because if you use it on OnValidate on table, you can encounter situation when validating by code (not by user) will throw you big error about transaction
Thanks a lot for the code man..It just hits the bull’s eye..!!
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
