I’m trying to auto populate some fields from a relate field.
I have got it all working except for one field: the email address field.
I’ve tried finding the different database field names but it just won’t work.
I cant say I have pulled the email address on a relate field before.
I would assume that it is not working due to the fact that the email address is held in its own table and not within the record that you are related to. so its not find the field. It might mean you need to go a couple steps further to pull the email address into the record.
without looking at how sugar is dealing with this it would be hard to determine the best way. you could create another ajax call to get the email address details on the return of all the related data above.
You could build a hook which adds the first email address to that field on save. this would then let you grab the email address that way. that would be easier than making a ajax call on the return of the data. you would need to handle how it deals with a user adding two email addresses, but then on that you could just take the primary email address each time.
That’s fine with just one email address, we never add more than one ever so I even got rid of the add button.
That would work very well when adding a contact from the contacts module, only thing is I use logic hooks to add contacts from directly within an invoice form, so how can I use a logic hook to add an email address to that contact too as that is also not working, every other field is though?
When adding contacts from within a invoice do you use a SQL query or create via the beanFactory?
If you use the BeanFactory then the logic hooks in that module(which is contacts) would fire when the Bean is saved which then should pull in the email address to that new field.
Thanks, I did it in the end with a query to add the address to the email_addresses table and then make it related to the contact with the email_add_bean_relate table
You wrote: “Thanks, I did it in the end with a query to add the address to the email_addresses table and then make it related to the contact with the email_add_bean_relate table”