Update reference field using name, not id? (Lookup field name)

  • 1
  • Question
  • Updated 3 years ago
  • Answered
This may sound a bit strange as to why I would want to do this, but I need to be able to enter a name into a text field and have it update a look up reference field. I can do this with the id, but I need it to relate based on name. So if I am in a field editor using the model Patient and Patient has a lookup field to "Illness " object, I need to be able to have a text field from patient choose the Condition 1 record based on name, not id.
The basic question is that I can update the field if I use the id of the illness record, but I can't get it to work using the name of the illness record. Is this possible?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Raymond,

I don't think I entirely followed you. Can you create your condition on Patient__r.Name rather than Patient__c (Or Illness__r.Name instead of Illness__c)?
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Thanks for your reply. I got all twisted up in the logic of this. I was trying to take something that was already built and convert it into something it was not. What I wanted to do was impossible. I need a junction object and it is easier to accomplish with a table. Once again, thanks for you help.