Default value for different locales

  • 25 March 2024
  • 2 replies
  • 31 views

Badge

Hello, 

I understand the concept of default value in Contentstack, but it seems that the default value is only possible in one language since there is just one expected value.

Is there a way or a proposed solution to have default values different based on the locale of the entry ?

 

Thanks.


2 replies

Hi @Xavier Valtech! Great question about default values for different locales. While Contentstack doesn't currently offer a single field with multiple default values based on locale, there's a solution using Contentstack's Automate.

 

Here's what you can do:

  1. Set a generic default value (e.g., "some text") for a multi-line field in your content type, in your master language.
  2. Create an automation with the following configuration:
    • Trigger: On entry update
      • Filter: If the multi-line field is empty
    • Step: Update entry with field (using the desired default value for the specific locale)

This automation will automatically populate the empty multi-line field with the appropriate default value based on the locale whenever a new entry is created or an existing entry is updated and that field remains empty.

 

I hope this helps! Let me know if you have any other questions.

Badge

Hello @michellegrady 

I understand that in theory I could use the automation, but I want to validate something because in practice it seems to not work well.

I didn’t find exemple on how to actually update an entry but I think I managed to do it by putting the actual json in the entry_data of the “Update an Entry” Action.

My action is triggered by an event “Entry Updated” of the “Entry Trigger”

 

It seems to work but what I think is happening is that : 

  • A user updates an entry
    • The entry is updated
  • The event is triggered asynchronously
    • The update action will update the entry

So what happens is that if I update something in the UI the event is not triggered yet and I will need to reload the page to see the actual change.

So if I just do a change, then publish my content it will not trigger the update of the data in time and it will publish the wrong data.

same if the trigger has an issue, then I assume that the change will not happen but nothing will prevent the editors to publish the incorrect content

 

Can you confirm if there is something I am missing to make it that editors using the UI can actually have the expected behavior without having to wait or refresh the pages ?

Reply