Get an value from a Bean

When creating a record from a sub panel of another record, I am truing to capture the parent record to use in a logic hook,

I have dumped the $bean and found the ID of the parent record 7 times in it, But having problem to referencing the id number (or parent bean) from it.

attached is the bean as it is quite large, The parent ID is: c635d587-496f-e0a0-8535-5f6db8f4289c

IT is referenced on lines:

  • 460
  • 3521
  • 4173
  • 4186
  • 4621
  • 7964
  • 8082

Any help how to call get this variable would be great, I am expecting something like
$bean->como_miscinv_como_sitescomo_sites_ida

Thanks

var_dump.zip (21.6 KB)

Hi there,

Is this relationship a Many to many or One to many, by chance?

I think Many to Many may be harder as I believe you’d have to go through the Relationship Tables
So, i’m not sure if “$bean->como_miscinv_como_sitescomo_sites_ida” would work as that field may not exist in the Contact’s table, (as far as im aware)

It might be worth having a look at the documentation around Beans/Relationships:


It looks like “get_linked_beans” or “load_relationship” might allow you to grab related m2m records

I’ve found a thread elsewhere too, where some users were discussing getting it to work:

Hopefully anything of the above points in the right direction!

1 Like

Thank you, I t was me being silly. Not sure why i was looking for the related bean inside there, I just needed to call the related bean first!

$siteBean = $bean->como_miscinv_como_sites->getBeans();

Aha! That’ll do it!

Glad you got it sorted :slight_smile: