Ok, I got a question that needs a quick answer.
I got a codeunit to import a csv, I can't use a dataport.
Amongst the fields are 3 option Fields, in the csv i got the values of their OptionStrings,for example Sales Order.
Now I need to put in that into the option field in the table, can I get the value of an Option based on the option string.
0
Answers
You can write code similar to the following:
TypeText := FORMAT(Type);
CASE TypeText OF
'Contract':
MESSAGE('Contract');
'Permanent':
MESSAGE('Permanent');
END
Hope this helps.
Chn
(to export an option as an integer: intDocumentType := SalesHeader."Document Type"; export the intDocumentType. It will export an integer and the the caption of the option).
Otherwise you can use EVALUATE. BUT it is language-dependent!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
I have very little info further, but I do have the database.
What I want is to get the integer value of the option based on a string.
For instance Sales Retour Order has an integer of 4, Verkoopretourorder is the dutch option for this.
I want to know of there's a way to get the numeric value based on the strings in the optionstrings.
RecRef: Type - RecordRef
FRef: Type - FieldRef
OptionText: Type - Text250
Code:
RecRef.OPEN(<Your Table Id>);
FRef := RecRef.FIELD(<Your option field id>);
OptionText := FRef.OPTIONSTRING;
I think this may help. Once you get the OptionString from the field and the string data from your file, you can compare the values and see which option it is. Now option values starting from 0, you can easily find out what the integer value will be.
Chn
EVALUATE(SalesHeader."Document Type",txtTheOptionValueAsText);
intDocumentType := SalesHeader."Document Type";
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
That wasn't a requirement in your question..
Look in codeunit 8611,
ValidateOptionValue(VAR FieldRef : FieldRef;OptionValue : Text[250]) Valid : Boolean
I added that we should both look in the optionstring as well as the optioncaption