text to option string

madm
Member Posts: 92
we have a code unit for importing text files to create sales orders.
for a short term measure, when we import, we need to use one of the data fields to trigger an option field..
the option field defaults to "No", and during the import the following is needed :
if data[x] = ABC then
option field := yes
however, this leads, understandbly to the can not convert from text to option..
from reading about this, i "guess" that i need to use optionfield::yes , but im not sure of how to go about this! (and i thought this would be an easy one!!)
for a short term measure, when we import, we need to use one of the data fields to trigger an option field..
the option field defaults to "No", and during the import the following is needed :
if data[x] = ABC then
option field := yes
however, this leads, understandbly to the can not convert from text to option..
from reading about this, i "guess" that i need to use optionfield::yes , but im not sure of how to go about this! (and i thought this would be an easy one!!)
0
Comments
-
Yes, you have to use :
OptionField := OtionField::yes ;
Please not that if your option is simply Yes/No, it is more easy to use a boolean field. In this case, you can write :
BooleanField := (data[x] = ABC);
or :
if data[x] = ABC then BooleanField := TRUE;0 -
Thanks for your replies. There are other options "available", hence the option field!
I have tried the suggestion (in the create header of the c.u)
as follows :
IF Data[20] = ABC THEN
SalesHdr."Field X" := SalesHdr."Field X"::Yes;
Although i dont get a compling error, when importing the text file Field X doesnt get populated with Yes0 -
madm wrote:Thanks for your replies. There are other options "available", hence the option field!
I have tried the suggestion (in the create header of the c.u)
as follows :
IF Data[20] = ABC THEN
SalesHdr."Field X" := SalesHdr."Field X"::Yes;
Although i dont get a compling error, when importing the text file Field X doesnt get populated with Yes
-Are you sure "SalesHdr" is the record you are saving
-Are you sure you put the code in the "OnAfterImportRecord"-trigger?
-extra : don't forget to do a clear of all variables in the fieldlist in the "OnBeforeImportRecord". If in a record a value is blank, it takes the previous value.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:madm wrote:Thanks for your replies. There are other options "available", hence the option field!
I have tried the suggestion (in the create header of the c.u)
as follows :
IF Data[20] = ABC THEN
SalesHdr."Field X" := SalesHdr."Field X"::Yes;
Although i dont get a compling error, when importing the text file Field X doesnt get populated with Yes
-Are you sure "SalesHdr" is the record you are saving
-Are you sure you put the code in the "OnAfterImportRecord"-trigger?
-extra : don't forget to do a clear of all variables in the fieldlist in the "OnBeforeImportRecord". If in a record a value is blank, it takes the previous value.
The import is done via a code unit previously written by a NSC. It does not contain the onAfterImportRecord sections.. Instead amongst others it contains a create header section : relating to the sales order header.
i have put the code in this create header section (which is where i can see other fields being populated), and within the section there is a clear saleshdr.
one further point which may help, is that data20 is actually being copied from data6, as this data6 may be set to blank depending on another circumstance. therefore data 20 always contains the original data.
however, the field populated by data20 shows the correct ABC etc, so this indicates that this process is working..0 -
Try this:
IF DELCHR(Data[20],'<>') = ABC THEN SalesHdr."Field X" := SalesHdr."Field X"::Yes;
The DELCHR with '<>' deletes blanks, CR,LF at the beginning and the end of the string.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions