You need to sign in to do that
Don't have an account?
How do i create an error message on Top of Detail Page?
Hi,
I have a requirement in which when i click on a custom button "generate eID" eID is generated. A Vf page is used as mediator to call the controller method with the taskid of the current task and the eID is generated and populated.
Now if the eID is already available and still we click on the button i want to display the error message on the top of the Detail page of current task.
Currently i have displayed the message on the VF page and with the Link to go back to the current task. but that takes to much time.
The Controller Class
public class eIDController {
public string theID{get; set;}
public Boolean errorAlert=false;
private final Task o;
// Constructor used to fetch the current Record
public eIDController(ApexPages.StandardController stdController)
{
this.o = (Task)stdController.getRecord();
}
//Method making the callout to WrapperDummy class
public PageReference autoRun()
{
List<ID> TaskIds=new List<ID>();
//It extracts the Id of the Current Record
String theId = ApexPages.currentPage().getParameters().get('id');
if(theId!=null)
{
for(Task t:[select ID,Activity__c,CustomerIdentity__c from Task where id=:theId])
{
//It checks if the Activity is null
if(t.Activity___c==null && t.CustomerIdentity__c != null){
TaskIds.add(t.ID);
}
//If it is Not Null it Throws An Error message
else if(t.Activity__c!=null && t.CustomerIdentity__c != null){
errorAlert=true;
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Activity already exists'));
return null;
}
else if(t.Activity_TRN__c==null && t.Customer_CIDN__c == null){
errorAlert=true;
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Customer Identity is Null'));
return null;
}
}
update TaskIds;
}
PageReference pageRef = new PageReference('/' + theId);
pageRef.setRedirect(true);
return pageRef;
}
}
VF page:
<apex:page standardController="Task" extensions="eIDController" tabStyle="Task" action="{!autoRun}">
<apex:form >
<apex:sectionHeader title="Auto-Running Apex Code"/>
<apex:pageblock >
<apex:pageMessages >
</apex:pageMessages>
<apex:outputPanel >
Click <apex:outputLink value="/{!$CurrentPage.parameters.id}"> Here </apex:outputLink> to return to the Custom object record
</apex:outputPanel>
</apex:pageblock>
</apex:form>
</apex:page>
i want to display the error message in the form of alert box on the Detail Page or in the form of error on the top of Detail page.
addError, javascript can be an option but not sure how to implement it