function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joseph Hurless 4Joseph Hurless 4 

Apex PickList Contact Trigger

Hey, admin here trying to learn more apex. Could anyone help me with some of these. I have 1 all set just working on code for number 2 currently.

1. Add a multi-select field to Contact that lists each species of animal (Cat, Dog or Bird) the Contact can own.
2. Using Apex, update the Contact record to automatically show all the species of pets a Contact owns when a Pet record is added or changed.
3. Using Visualforce, create a page that lists all Veterinarians entered on Pet records.
4. On that same Visualforce page, show all Pet records associated with a Veterinarian when one of the Veterinarians in the list above is selected.
Show all the fields for each pet, and allow the Vaccination Date field to be updated for each pet, and saved for all shown pets at once.
 

Pankaj_GanwaniPankaj_Ganwani
Hi Joseph,

2. This can be achieved through trigger on pet object.
3. You will have to create a wrapper class for showing all Veterinarians on Pet records and bind it with the page. Wrapper class structure:
 
public class VetWrapper
{
    public Veterians__c objV{get;set;}
    public Boolean isChecked {get;set;}
}

4. Use onChange event on <apex:inputCheckbox> tag and pass the value of Veterinarian Id to Controller and fetch the related Pet details and bind them with page.