You need to sign in to do that
Don't have an account?
Yadhagu L
How can I get the parent ID from the related list
i have a custom button in campaign object related list of campaignmember object and I need to call vf page that will bring the campaign record id using the custom button.
Hi Yadhagu,
To create a custom button on the Campaign Member related list in the Campaign object that calls a Visualforce page and passes the Campaign record ID, you can follow these steps:
1. Create a Visualforce page:
Here's an example of a basic Visualforce page that retrieves the Campaign ID:
2. Create an Apex controller:
Create an Apex controller that retrieves the Campaign record ID and redirects to the desired page. Here's an example of an Apex controller:
3. Customize the Campaign page layout:
Now, when you navigate to the Campaign object and view the Campaign Member related list, you will see the custom button. Clicking on the button will invoke the Visualforce page, retrieve the Campaign record ID, and redirect to the desired page or perform any other desired logic. Make sure to customize the redirectToPage() method in the Apex controller to implement your specific logic or redirect to the appropriate page using the campaignId parameter.
Note: Ensure that the Visualforce page and Apex controller have the necessary access and visibility settings based on your organization's security requirements.
Hope this will be helpful.
Thanks!
All Answers
Hi Yadhagu,
To create a custom button on the Campaign Member related list in the Campaign object that calls a Visualforce page and passes the Campaign record ID, you can follow these steps:
1. Create a Visualforce page:
Here's an example of a basic Visualforce page that retrieves the Campaign ID:
2. Create an Apex controller:
Create an Apex controller that retrieves the Campaign record ID and redirects to the desired page. Here's an example of an Apex controller:
3. Customize the Campaign page layout:
Now, when you navigate to the Campaign object and view the Campaign Member related list, you will see the custom button. Clicking on the button will invoke the Visualforce page, retrieve the Campaign record ID, and redirect to the desired page or perform any other desired logic. Make sure to customize the redirectToPage() method in the Apex controller to implement your specific logic or redirect to the appropriate page using the campaignId parameter.
Note: Ensure that the Visualforce page and Apex controller have the necessary access and visibility settings based on your organization's security requirements.
Hope this will be helpful.
Thanks!
If you're using the onclick javascript for a detail page custom button, use the field type for the parent.
E.g. if I'm trying to put a button on the Contact related list off the Account page, I'd do this:
alert('{!Account.Id}');
The account.id referenced will be from the parent object.
Also please refer these discussions for further understanding :
https://salesforce.stackexchange.com/questions/334967/get-the-record-id-from-the-related-list
https://stackoverflow.com/questions/71395168/how-to-get-parent-id-on-related-list-in-salesforce
If this helps , please mark this as Best Answer.
Thank you.