EZP-21735: fixed using undefined variable

This PR resolves issue https://jira.ez.no/browse/EZP-21735

This fixes usage of undefined variable.
Manually tested.