+ Start a Discussion
Jacek DJacek D 

Using a trigger to do HTML field update?

Hi,

 

I've been working in Salesforce for 4 months now and figured that Apex is a much more elegant way to solve some issues I ran into. Being relatively clueless about coding, but curious and open-minded, I am hoping you guys can help me.

 

I ran into this issue while populating a child object: The child needs to display the content of a HTML field of its parents. While text only can be done with a field update, the parent also includes a graphic. Is that possible?

 

And if so, how can I trigger field updates across objects with Apex (meaning, how do I create a link to a different object)?

 

Thanks,

 

Jacek

bob_buzzardbob_buzzard

The graphic in an HTML field will just be an HTML img component I'd imagine, so as long as the field on the child object is also an HTML field you should just be able to copy it.

 

With regard to the second part of your post,  if you have a child object in your code, it will have a lookup relationship to its parent, so you can use that to retrieve the parent.

 

Below is a quick example using a contact (child) to retrieve its parent (account);

 

 

Contact cont;
Account acc;

... set up cont here ...

List<Account> accs=[select id, Name from Account where id=:cont.AccountId];

if (!accs.isEmpty())
{
   acc=accs[0];
}