Hi all,
We are encountering an issue with a Cloud Rule that assigns sequential unique values to an attribute based on certain conditions. The logic currently works by iterating through possible values until it finds one that is not in use. However, after approximately 600–800 iterations, the rule fails and throws a full-stack error.
For example, if the user is internal, the value should start at 10000. If 10000 is already taken, then assign 10001, if that is taken then 10002, and so on until an available value is found. This approach works initially but eventually fails when the iteration count becomes too high, and we end up having to manually update the rule after every few hundred identities.
Our question is: how can this be solved without constantly updating the rule? Do other implementations use a base field or some kind of counter that can be updated automatically without changing the rule logic? Are there recommended best practices for this scenario? For example:
Using a persistent counter stored in an attribute or configuration object and incrementing it for each new identity?
Storing the counter in an external system and calling it from the Cloud Rule?
Querying the highest existing value and incrementing from there instead of brute-force iteration?
Thanks in advance,
Antonio