Best practice with property naming and property referencing

This article arises because of a problem encountered with using a dash or hyphen to create a Total Compensation field, but see here for further context

The problem lay with one element, node.HQ-Reimbursement.

OrgVue in its expression calculations will interpret a '-' as a minus used within "dot notation", so the null record being returned, that the ticket advised, is based on the inability to resolve the expression "HQ minus Reimbursement".

If that part of the expression was altered so that it reads node.HQ_Reimbursement, then the calculation should work correctly.

For completeness, it is possible to use non-dot notation and refer to node["HQ-Reimbursement"] but as a matter of best practice, we would advise against including hyphens i.e. '-' in key names.

Note, OrgVue's enhanced capabilities allow you to access a property via a loose name match. So, even though the key here is HQ-Reimbursement, we can access it via any number of different forms:

node. HQ_Reimbursement

node. HQReimbursement

node. hqReimbursement

Best practice would be to use and underscore (_) where it is desired to have separators between words in property keys, and avoid spaces in property keys.

Have more questions? Submit a request

Comments