Full Version: [SOLVED] Check if a record has siblings on creation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK, I'm pretty sure we can do this, just not sure how exactly:

I want to create a workflow that runs when a record of module A is created. Records from module A contain a UI10 type field to module B. I want to check if this record (the new, module A type record) is the only one related to module B through that UI10 field. If that condition is met, a checkbox should be true, otherwise it should be false.

Or would it be better to do this through a businessmap and use some aggregation expression?
do you mean that all the other records in module A must not be related to B?
I don't see any way of doing that. I would create an aftersave event handler
Could be nice to add this to the workflow conditions? Like a condition that says "Is unique through" and then the second dropdown would present you with the UI10 fields you could use the check on? I could create a PR.
I would actually see it more useful as a validation, but I guess a condition would be good too. Sure , go ahead
Yeah I can see how it would work as a validation, but that won't allow actively setting some checkbox (for example) behind the scenes. Maybe just do both.
OK so here is the PR. I now created it so it only checks if the parent of the current record has children like the child record or if the child record is unique in respect to its parent. We could also alter it so that it returns a count, so you can enter a number in the box.
Now that I see the code I understand better what you are trying to do. I think the "EXISTS" condition could fit your needs. If I remember correctly this condition permits you to know if there exists another record with the same value in a field. In this case, if EXISTS returns true there is another record with that value, if not, the record being saved is unique.

Would that be equivalent to the new condition you added?
Yes it would. I'd like to use the QG to avoid duplicate code, but as I mentioned in the PR, while posting the PR I came upon the thought that it might be nice to expand it beyond a true/false evaluation and let you evaluate against a number so you can tie some action to the nth record. So you could say "change the 5th child's name to John", poor John.
I agree, very interesting
For anyone interested: the workflow system now supports this