Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check if a record has siblings on creation
#1
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?
Reply
#2
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
Joe
TSolucio
Reply
#3
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.
Reply
#4
I would actually see it more useful as a validation, but I guess a condition would be good too. Sure , go ahead
Joe
TSolucio
Reply
#5
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.
Reply
#6
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.
Reply
#7
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?
Joe
TSolucio
Reply
#8
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.
Reply
#9
I agree, very interesting
Joe
TSolucio
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)