Option value != OptionML value

Do you need some way of getting the Option value instead of the OptionML value from an Option field?

It is not so straight forward as one should think, but with this simple function the work is done for you:

PROCEDURE GetOptionValue@1000000002(TableId@1000000001 : Integer;FieldId@1000000000 : Integer;Value@1000000002 : Integer) : Text;
VAR
  TableRef@1000000003 : RecordRef;
  FieldRef@1000000004 : FieldRef;
BEGIN
  //Example:
  //  MESSAGE(KMCTools.GetOptionValue(DATABASE::"Sales Line",SalesLine.FIELDNO(Type),SalesLine.Type::Item));
  TableRef.OPEN(TableId);
  FieldRef := TableRef.FIELD(FieldId);
  EXIT(SELECTSTR(Value+1,FieldRef.OPTIONSTRING));
END;

Free of charge – but use on your own risk…

Leave a Reply

Your email address will not be published. Required fields are marked *