board logo
WUICTeam
  • WUICTeam
  • 100% (Exalted)
  • Newbie Topic Starter
5 days ago
Question
I call wtoolbox.enqueueNotification({ roleId: 21, message: '...' }) as a normal user. The request does not fail and the users I listed explicitly get the notification, but the role members get nothing and the method returns false. What is happening?

Answer
The server dropped the role. A role that is not allowed is discarded, but the rest of the call goes through: explicit users (userId/userIds) still receive the notification, and the response lists what was dropped in refusedRoleIds, with the reason for each in refusedRoleReasons. The client helper turns that into false.

There are three reasons, and each has a different fix:

  • role_fanout: sending to whole roles is allowed only to the superadmin, to the roles listed in the notificationRoleFanOutRoles setting (role ids or names separated by commas, * = every non-guest user, missing = superadmin only), or, from a saved workflow, to a role that the workflow names as a literal number in its own notification call.
  • too_many_recipients: a non-superadmin can reach at most 50 recipients per call. If the users of the role would push the call over that limit, the whole role is discarded, not truncated.
  • role_resolution_failed: the users of the role could not be resolved on the server.


If there is no recipient left at all, you get a 403 with the same reason instead of a partial success.

Typical fix
In the app settings, allow the sender's role:

"notificationRoleFanOutRoles": "Managers,Supervisors"

In a workflow callback, write the role id literally inside the object:

await wtoolbox.enqueueNotification({ roleId: 21, type: 'workflow', message: 'Order approved' });

Pitfall to avoid
A roleId taken from a variable does not count as "named by the workflow": the server only recognizes the number written in the call. For a computed role, use notificationRoleFanOutRoles. Also, do not treat the HTTP 200 as success: check refusedRoleIds or the false return value.

Documentation: Notifications