How can I sync in the content and trigger the rule

In our project we have created a rule to further publish the content to Kafka.

To prefill the CMS with some content we are using “sq sync in content” command, I can see the data is getting exported to Squidex but the corresponding rule is not being triggered.

Rules is configured as per below condition.
event.type == ‘Published’ || event.type == ‘Updated’ || event.type == ‘Deleted’

Could you please help is this the expected behavior, if yes, what can be done to make sure rule is triggered.

Hi,

the sync command does not bypass the rule system. You can use the rule simulator to check what happens (1). The skipped columns shows the status (2) and you can expand the item to get more information (3).

There were some issues at my end only, I can see the data now getting published to Kafka.

Thanks for your response.

1 Like

I have one more question about this.
This command "sq sync in " will export the content to cms as well, but this one is not triggering the rule. Although if I just export the configuration (schemas, rules, etc…) first (remove the contents folder and use the same above command) and then export the content using "sq sync in -t content " I can see the rules are triggerd.

Hi,

there are 2 things that make it different for the sync:

  1. The rules are synced after the contents, therefore it might happen that the rule is not available yet, when the content event is handled.

  2. Rules are cached for a few minutes, so even if we would change the order, the rule is no necessarily available yet.

So you have 2 options:

  1. Sync the rules first, then the contents.
  2. If you go to a rule page you should see a button to replace the full rule.

Click the context menu (1) and either choose to replace the events (2) or the states (3).

The difference between (1) and (2) is the following.

Lets say you have created a content item and updated it twice and then published it, then 4 events are created:

  • ContentCreated
  • ContentUpdated (2x)
  • ContentPublished

So the rule is triggered 4 times.

If you replace from state the rule is triggered only once.

I understand it now, thanks for the support.