ValueType for OptionSet and DataElement

is there any case when DataElement and its associated OptionSet can have different ValueType?

2 Likes

Hi @zubair ,
Good question. I do not see a good reason for this to happen. At least in the Maintenance app UI, when you select an Option set of say “Text” the data element value type automatically gets assigned the same type as the option set. This is also enforced (in later versions of DHIS2) via the API. If you attempt to alter a data element value type which has an option set of type “Text” to say “Number”, you get this message.

{“httpStatus”:“Conflict”,“httpStatusCode”:409,“status”:“ERROR”,“message”:“Data element value type must match option set value type: TEXT”,“errorCode”:“E1115”}

So, I think the answer is no, and it looks like there are validations in place at least in the API to prevent this situation from happening. Having said that, it would not surprise me if in earlier versions of DHIS2 (and thus older databases) would allow this to happen.

Best regards,
Jason

1 Like

@jason that’s what I am checking now. The version we did include this validation in.

1 Like