Invalid Option Type Error!
Hi, I have a quick question.
I am trying to calculate the age of a person. Once I have a age I have to set it to appropriate Type. For example if age is less then 18, then the type would be "Child", if the age is less then 65, the type would be "Adult, and so on.
This is the code snippet that I have so far:
InputDate := TODAY;
Year := DATE2DMY(InputDate,3);
BirthDate := Customer.Birthdate;
BirthDay := DATE2DMY (BirthDate, 3);
IF (Customer.Birthdate = 0D) THEN
BEGIN
Job."Primary Consumer Type" :='';
END;
PrimaryType := (Year - BirthDay);
CASE PrimaryType OF
1..17:
BEGIN
Job."Primary Consumer Type" := 'Child';
END;
18..64:
BEGIN
Job."Primary Consumer Type" :='Adult';
END;
ELSE
BEGIN
Job."Primary Consumer Type" := 'Senior';
END;
END;
The error Message I get on this line (Job."Primary Consumer Type" :='';) is: Type conversion is not possible because 1 of the operators contains an invalid type. Option := Text
Primary Consumer Type is an Option field with the following options child, senior, adult, etc
I know the reason of the error, I just dont know how to fix it.
I am trying to calculate the age of a person. Once I have a age I have to set it to appropriate Type. For example if age is less then 18, then the type would be "Child", if the age is less then 65, the type would be "Adult, and so on.
This is the code snippet that I have so far:
InputDate := TODAY;
Year := DATE2DMY(InputDate,3);
BirthDate := Customer.Birthdate;
BirthDay := DATE2DMY (BirthDate, 3);
IF (Customer.Birthdate = 0D) THEN
BEGIN
Job."Primary Consumer Type" :='';
END;
PrimaryType := (Year - BirthDay);
CASE PrimaryType OF
1..17:
BEGIN
Job."Primary Consumer Type" := 'Child';
END;
18..64:
BEGIN
Job."Primary Consumer Type" :='Adult';
END;
ELSE
BEGIN
Job."Primary Consumer Type" := 'Senior';
END;
END;
The error Message I get on this line (Job."Primary Consumer Type" :='';) is: Type conversion is not possible because 1 of the operators contains an invalid type. Option := Text
Primary Consumer Type is an Option field with the following options child, senior, adult, etc
I know the reason of the error, I just dont know how to fix it.
0
Comments
-
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"Senior";
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"Child";
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";
etc...0 -
When i tried doing the way you suggested, now I get a different error:
"A Variable was expected. For example:
MyVar
Customer.Name"0 -
Can you post your new code?0
-
Actually never mind, it works. I forgot to take the single Quotations out. hehehhee...
Thanks.
Just for knowledge sake, what does putting the code like this (Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";) actually achieve. Just in case I have similar issue some other time, I want to be able to know how to fix it myself.0 -
also,for readability reasons:
BirthDay := DATE2DMY (BirthDate, 3);
shouldn't BirthDay actually be named BirthYear0 -
Options are stored as integers.
Job."Primary Consumer Type" := 0;
is the same as
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";
This is much easier to understand: option type = option type:: (of) blank.0 -
Ohhh...OK. I guess that makes sense. Thnx everyone for there help.
I really appericate it.
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