Rework javascript getProperty API to handle missing properties better #4900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identify the Bug or Feature request
closes #3028
Description of the Change
This changes the javascript
getProperty
function to look up the value in the campaign property type defaults if it's missing, and returnnull
instead of"null"
if you don't have permission to get that token's properties or the campaign doesn't have that property either, for improved ergonomics of null-handling in javascript.This also adds
getRawProperty
which returnsnull
if it's not set, andgetEvaluatedProperty
which may evaluate the value as a macro.Possible Drawbacks
If users of getProperty were checking for the value being missing with something like:
then this will now end up with value being
null
.getProperty
is the most desirable name for the most common operation. It's possible that most campaigns use properties that should be evaluated so should use the shorter name, and the form ofgetProperty
that only falls back to the default value should be called something likegetUnevaluatedProperty
orgetDefaultedProperty
.Release Notes
token.getProperty
returnnull
instead of the string"null"
when properties are missing or not permitted to be read.token.getProperty
return the default value for the token type if the value was not set on the token.token.getRawProperty
for uses that shouldn't fall back to defaults andtoken.getEvaluatedProperty
for uses that should use calculated defaults.This change is