Shouldn't you simply be able to use `$object->getObjectID()` instead of `$object->$databaseIndexName`?