This is the code I use to read the data from the TYPE field. This code fails on the first CASE statement with the error "Function argument, value, type or count is invalid"
z_transaction_value = objHeaderData.FIELDS['FOREIGN_GROSS'].VALUE - objHeaderData.FIELDS['FOREIGN_AMOUNT_PAID'].VALUE
DO CASE
CASE objHeaderData.FIELDS['TYPE'].VALUE = '1' && Sales Invoice
z_os_value = z_transaction_value
CASE objHeaderData.FIELDS['TYPE'].VALUE = 2 && Sales Credit
z_os_value = 0 - z_transaction_value
CASE objHeaderData.FIELDS['TYPE'].VALUE = 3 && Sales Receipt
z_os_value = 0 - z_transaction_value
CASE objHeaderData.FIELDS['TYPE'].VALUE = 4 && Sales Receipt On Account
z_os_value = 0 - z_transaction_value
CASE objHeaderData.FIELDS['TYPE'].VALUE = 5 && Sales Discount
z_os_value = 0 - z_transaction_value
OTHERWISE
MESSAGEBOX("A Customer Transaction Type: " + ALLTRIM(STR(objHeaderData.FIELDS['TYPE'].VALUE)) + " Not Known To OrderWise Has Been Encountered" + CHR(13) + "While Obtaining A Balance For Customer: " + ALLTRIM(this.z_account_number_to_post_to) + CHR(13) + "Please Report This To Technical Support",48,"STOP!"

ENDCASE
(Best to copy this into somewhere where you can view it better)
The offending line being
CASE objHeaderData.FIELDS['TYPE'].VALUE = '1'
I have tried the following:
CASE STR(objHeaderData.FIELDS['TYPE'].VALUE) = '1'
CASE VAL(objHeaderData.FIELDS['TYPE'].VALUE) = 1
Both return the same error message
I can write to the field however by using:
objHeaderData.FIELDS['type'].VALUE = 1
which suggests that even though the field is byte it accepts a numeric value.
Any more ideas? I would be most grateful as I am pulling my hair out!