Conditional write to multiple data store entities

I have a situation like this with saving data to database:

- in employee update process user can change employee's personal and address data

- address is joined to employee via foreign key addressId on employee entity

- if address is not chosen from codebook it goes on approval to "address admin"

- id address admin approves new address it should be added to the codebook

- this means following: If user updated personal data and added new address (which is approved in the next step), data will be stored to employee table and to address codebook table. If user updated personal data and added existing address, only employee data should be stored to employee table.

How can I configure this conditional save using Write to Multiple Data Store Entities?

Am I allowed to use expression editor to configure IF statement? Is this statement below correct (if I assume I have process variable addressAddedFlag)?

if (pv!addressAddedFlag = true,

{{entity:cons!EEDM_EmployeeDataStoreEntity, data:pv!employee},{entity:cons!EEDM_AddressDataStoreEntity, data:pv!address}},

{{entity:cons!EEDM_EmployeeDataStoreEntity, data:pv!employee},{entity:cons!EEDM_AddressDataStoreEntity, data:{} }}

)

  Discussion posts and replies are publicly visible