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.
0
Answers
"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.
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Your code should look roughly like this:
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..!!