0

I want to give a file upload and record insert success message. I am udsing the below apex class. Can anyone help me how to give success message.

public with sharing class devoteeinsert{
    //Variable Declaration
    private final Devotee__c con;
    public string Conlastname{get;set;}
    public string conphone{get;set;}
    public string conemail{get;set;}
    public string Conmobilephone{get;set;}
    public string Accid='';
    public blob Photo{get;set;}
    public string photoname{get;set;}
    public string photourl{get;set;}
    public string mail{get;set;}
    public string age{get;set;}
    public Attachment tAttachment{get;set;}
    public String response {get; set;}
    public string message {get;set;}

    //Contstructor 
    public devoteeinsert(apexpages.standardController controller){
        con=(Devotee__c)controller.getRecord();
        this.tAttachment = new Attachment();
    }



    //this method updates the Contact with photourl and insert The Attachment Record
    public void UploadPhoto(){

        try{

            con.Name= conlastname;  
            con.First_Name__c= conemail;
            con.Family_Name__c= conphone;
            con.Gender__c= conmobilephone;
            con.Email__c = mail;
            insert con;


            Attachment a = this.tAttachment.clone(false, true, false, false);
            a.OwnerId = UserInfo.getUserId();
            a.ParentId = con.id;
            this.tAttachment.Body = null;
            insert a;


        }catch(Exception e){
            system.debug('Exception message'+e);
        }
        return null;
}
}
1
  • Salesforce default functionality when successfully saving a record is to redirect to the saved record. I'm not saying you must use that, but it might be beneficial for your users to have a consistent behaviour throughout the platform. Makes you think. Commented Aug 3, 2015 at 7:49

1 Answer 1

2

try this

insert a;
message = 'Record Created Successfully.Thank you!';
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,message ));

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .