Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
07-12-2019, 10:37 AM
(This post was last modified: 09-19-2019, 12:44 PM by Guido1982.)
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?
Posts: 3,565
Threads: 36
Joined: Apr 2014
Reputation:
49
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
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
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.
Posts: 3,565
Threads: 36
Joined: Apr 2014
Reputation:
49
I would actually see it more useful as a validation, but I guess a condition would be good too. Sure , go ahead
Joe
TSolucio
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
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.
Posts: 3,565
Threads: 36
Joined: Apr 2014
Reputation:
49
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
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
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.
Posts: 3,565
Threads: 36
Joined: Apr 2014
Reputation:
49
I agree, very interesting
Joe
TSolucio
Posts: 855
Threads: 238
Joined: Nov 2015
Reputation:
96
For anyone interested: the workflow system now supports this