Condition to reference row in the same model

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have one model that I am trying to only show the records where field A doesn't equal field B (on the same record). Both fields are lookups to the user object. Is there a way to do this with conditions? I'm not sure if I'm having a brain fart or if this just isn't possible.
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
let me make sure I understand correctly,

Field A and Field B are 2 different lookup to same object?

If yes, it seems simple, maybe too simple, so I prob missed something lol

But in case . here's an example I just tried:

Condition would be  FieldA Is not equal to value of a field from another model, and select same model + Field B

Here's an example



Hope it helps
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
My understanding is that will only compare to the FIRST row from the same model. I am looking to compare each row to itself. The model conditions specify the SOQL sent to the server, and I don't think there is a way to compare each row to itself in that way. But it seems simple, so I'm not sure what I'm missing.
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
that's not an issue either, as you had not mentioned you were using a table, I thought this would not be relevant.

You have to change the value from "Fields from the First row" to "Fields From any row returned...."

Not sure what is the "official way to do that" , but I do it this way:

-Create condition as i showed above , then Change content (in value) to "result of a subquery", then without saving, change it back to "Fields from another model", and now you will see the "from any row..." condition appear

Hope it helps
(Edited)
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I would just add a formula field to your object that returns a check mark if Field A equals Field B and then create a condition that filters your model based on that field.