SugarCRM Developers on Twitter

HOWTO: Get related bean record details from the vardef.

We had this question asked internally here at Sugar the other day from one of our PS team members:

I am working on Smarty function to get related beans for MultienumField. Relationship Name, module and RHS field name is required for smarty function. Can I set these fields in vardef?

David Wheeler chimed in with a great solution to the problem, which should be helpful for any of us needing to leverage the vardefs to get more information for a related field.

You can’t directly get the relationship name or module from the vardef for relate fields in all cases. The Link field is what you need rather than the relationship name since that is how relationships are accessed.

If you have a relate field that a vardef with: “rname” => “description” “link” => “accounts”

you can then pull the related accounts description field with something similar to: