If(isempty) -> Update a single select

Hi,

Is there a way (preferably with a formula) to set a specific single select option ONLY if no single select option is set?

If scripting is needed, I can’t script yet unfortunatelly. :smirk:

Thanks

@ChrisG once sent me an email about this. This one I found back. Maybe this will be of use to you as well!

Hi Marloes,

Unfortunately, there is currently no way to dynamically choose a single select value.

However, there are a couple of possible workarounds:

  1. Use scripting :frowning:
  2. Use a formula that relies on an entity query, but only if you can be certain that there is already at least one entity in the db that is in the desired state
  3. Use a two stage process

For #2, in your case the formula would look like this:

If(IsEmpty([Step 1 ActiveCampaign activiteit].Contact.[Lead via]), Contacts.Filter([Lead via].Name = “Active Campaign/Mailblue”).Sort().First().[Lead via], [Step 1 ActiveCampaign activiteit].Contact.[Lead via])

I hope you can figure out how it works: it basically checks if the Contact’s ‘Lead via’ field is empty, and if it is, then it looks through all the Contacts to find any for which the ‘Lead via’ value is “Active Campaign/Mailblue”, picks the first one and gets its ‘Lead via’ value. Otherwise, it just uses the existing value of ‘Lead via’ for the Contact.

It’s not pretty, and as I say, will only work if there is at least one Contact in the database that already has the ‘Lead via’ value set to “Active Campaign/Mailblue”.

For #3, you don’t update the ‘Lead via’ field in the main automation but instead you utilise an extra helper field (checkbox) which you update in the case that the Contact’s Lead via’ field is empty:

If(IsEmpty([Step 1 ActiveCampaign activiteit].Contact.[Lead via]), true, false )

Then you have another automation that runs when this helper field becomes true, and sets the ‘Lead via’ field to “Active Campaign/Mailblue” (and clears the helper field I suppose).

I probably would recommend method 3 because it is more robust.

Cheers,

Chris

Can’t you just use the default value on your single select?