I need to make a record-like query for a 1 to N relationship, in which it only returns the values of the parent record if all the values in the N relationship meet a condition. Example :
I have a record called "Need" and it is related to another called "needchangestate" through a relationship 1 to N, I need it to return only the needs where all the needchangestate meet a condition, if all the elements of the relationship N do not meet the condition, the element Need should not appear
Currently it returns me an investment where the condition is met in at least one of the records of the relationship N but this is not what I am looking for.
Discussion posts and replies are publicly visible
What about one or two custom fields that hold the number of these states?
I have not achieved it through custom fields, if you can think of a way, please share it
This does depend on how dynamic you want this functionality but if there is one (or not many) specific things you want then custom record fields do work. One way to do this is to have two "Aggregate Related Record Fields" custom record fields in the parent record (in your case, the "Need" record) that looks at the child record. One counts the number of children where decision is FALSE (`countOfNoDecision`) and the other counts the number of child records (`countOfAllDecisions`).
Then in your query you ask for only Need records where `countOfNoDecision` = `countOfAllDecisions`.
I can't do your solution due to an error in the expression
Apologies, it needs a third custom record team to do the comparison.
Correct, finally I saw that this was the option but I don't like it very much because we are creating 3 custom fields to make a calculation but those fields really do not provide any value, I think the option of extracting the results is better with the option of first extracting the elements that do not meet the condition, then those in which at least one meets the condition and then making a difference.