I have a custom database [object] called ‘Trainee__c’
And added a custom button that shows on each record,
I followed this website:
Create custom Button using Apex code
Very nicely explained
This code is only internally used,
My VisualForce code is
<apex:page standardController="Trainee__c" extensions="templicenseemail" action="{!doSomething}">
<apex:pagemessages />
</apex:page>
My APEX code is [This is only a portion of the code]
public with sharing class templicenseemail {
private ApexPages.standardController standardController;
public Trainee__c trainee { get; set; }
public templicenseemail(ApexPages.StandardController controller) {
this.standardController = standardController;
}
public PageReference doSomething()
{
trainee = [SELECT Email__c,First_Name__c,Institution__c,Last_Name__c FROM Trainee__c
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO, trainee.Email__c ));
return null;
}
}
I added the button in the custom layout for ‘Trainee__c’ object,
The button redirects the page to an empty page and displays the current Trainee__c record email address.
I want the email message to be displayed on the same record page,
How can I prevent the page from being redirected to an empty page?