Announcement: some changes in EventData.getInputValue() and Map

lock
push_pin
done
Answered
1

A bug that has been around for ages in Maps in Service/CRMScript is that trying to get a value for a key will actually insert the key it into the Map. We have decided to fix this bug specifically in the EventData class so that calling EventData.getInputValue(String key) or EventData.getStateValue(String key) now will not insert the key. We believe the risk for this breaking any existing customizations is extremely low, but we still wanted to notify you here. If, for some reason, you have something like this, you need to clean it up:

EventData ed = getEventData();
if (ed.getInputValue("foo") == "bar") printLine("foo is bar");
if (ed.getInputValues().exists("foo")) printLine("foo exists"); // This used to be true, but will now be false.

This change will come in the next release in a couple of weeks.

For the Map class, we do not dare to introduce the same change. Map.get(String key) will still have the side effect that the key will be inserted (with an empty value). However, we are introducing a new method, Map.getWithFallback(String key, String fallback). This method will return the value of the key if found, and if the value is not empty. If the key does not exist, or the value of it is empty, the function will return the fallback string. And the key will not be inserted into the Map.

23 Nov 2022 | 09:54 AM

All Replies (1)

Nice, the Map.getWithFallback method will be handy!

23 Nov 2022 | 09:55 AM

Add reply