+ Start a Discussion
Patricia LimPatricia Lim 

VF to 'add product' on a custom object product related list?

Hi all,
After some digging around the Trailblazer community, I discovered that adding this funcitonality to custom objects can be done with VF and apex. I am learning visualforce anyway, so I don't mind this method.

For context, my organization awards scholarships. Where scholarship is the product, and our recipients are a custom object 'recipient'. Initially, I created three products and added the product related list to the recipient page layout, but cannot add products, only create new ones.

Ultimately, I need the ability to add products to a contact. Ideally, at the end I envision that there will be a scholarships related list displaying the name of the award, the amount, and the year that the recipient received it.

User-added image

Where the year might be something only inputted when adding a new scholarship to a recipient. Just like in adding products, there is a date field.

User-added image
Suggestions are welcomed!
Thank you!
ShirishaShirisha (Salesforce Developers) 
Hi Patrica,

Greetings!

Can you please confirm,if you have any relationship between these two Objects.If yes,who is the parent and child.

Also,if you would like to display the scholorship(product) on the Custom Object(recipient) then you can simply create the lookup relation on the Product to Recipient then you will be able to have the related list with add product button.

Then,you can create the formula fields on Product based on the parent fields which will be updated whenever there is any change.

Otherwise,you can create process builder to update based on the Parent record changes.

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Patricia LimPatricia Lim
Thank you Shirisha.
There is a lookup relationship where product is the child and custom object 'recipient' is the parent.
Unfortunately I do not see the ability to add a product to my custom object.
See photos below:

This is the awards related list on the custom object record:

User-added image

This is what I am trying to achieve, except not with opportunities, but with custom object recipient:

User-added image
 
ShirishaShirisha (Salesforce Developers) 
Hi Patricia,

Product is the standard Object and if you would like to have the Product related list on your custom Object Recipient then you will need to create the lookup relationship field on the Product to Recipient then the related list of the Product will be added to the Recipient same like Opportunity.

Thank you!
Patricia LimPatricia Lim
Hi Shirisha,
I already have a lookup relationship from the product to the recipient.
The trouble is that there is no 'add product' button like there is for opportunity.