When I create/update entities via the API (curl), the relevant Rules are not triggered.
Am I missing something, or is this intentional?
When I create/update entities via the API (curl), the relevant Rules are not triggered.
Am I missing something, or is this intentional?
Rules should be triggered regardless the way of change (API, UI, etc.).
I suggest to check that other rules are executing well(no rule queue overload in your workspace at the moment). Then probably check that you actually do the change that is expected in trigger. If you make an API call that changes nothing, rule will not be triggered.
@Sergey_Truhtanov
There appears to be a bug here:
This Rule does not trigger when an external API call creates a “Trigger” entity with Name containing “Create”:
This Rule will only trigger on entity creation if I remove the “Name contains” filter.
It is easy to reproduce reliably - the following script correctly creates entities, but the Rule is never triggered, even if the entity Name contains “Create”. The Rule will trigger only if the Name filter is removed.
#!/usr/bin/env bash
declare cmd=$*
#declare FiberyAPIkey='...'
#declare fiberyUrl=https://xxxxx.fibery.io/api/commands
cmd=${cmd//\\/\\\\} # Escape backslashes
cmd=${cmd//\"/\\\"} # Escape dquotes
date=$(date)
cmd='[{"command": "fibery.entity/create","args": {
"type": "MISC/Trigger", "entity": {
"MISC/Name": "'$date'",
"MISC/Command": "'$cmd'"
}}}]'
if result=$( curl --silent -X POST "$fiberyUrl" -H "Authorization: Token $FiberyAPIkey" -H 'Content-Type: application/json' -d "$cmd"
) && [[ $result =~ '{"success":true' ]]; then
echo "SUCCESS - $date"
else
echo -n "FAILED - $date : "; echo "$result" | sed 's/.*"message":"//; s/\\n/\n/g; s/\\t/\t/g; s/","data":{/\n/'
fi
Will try to reproduce and fix, thanks for details.
Will write here when the issue will be resolved
Hello.
I’ve checked he issue and it works as expected, filter is applied correctly.
But I’ve remembered one specific behavior of rule filters. I think we’ve discussed it in some other topic in community.
Rule Filter is executed on the actual data at the moment of Rule execution.
There are 2 possible behaviors for Rule Filters: either like above, or execute Rule Filters on an entity, that was on the moment of a change.
Second option is much more complex. In Filter you may use Fields, that are not part of a change, that triggered a Rule. Also Filter allows to operate on related collections, and we may even allow formula expressions there in future. So we decided to stick with operating on current data for now.
This may lead to unexpected results. Imagine you’ve created an entity and have a Rule that changes it’s Name. Then you have a rule that subscribes to entity creation, and it won’t be executed, as new Name will not satisfy a Filter.
Also note, at the moment we don’t allow to change order of a Rule, they should be executed in the same order you see them on UI (so sorted by creation date).
If you are sure this is not the case for you, please confirm, I’ll dig deeper.
Thanks for looking into this @Sergey_Truhtanov
My apologies – this was a stupid error on my part, checking the wrong field (Name vs Command)