Skip to main content
added tag
Link
deleted 1029 characters in body
Source Link
Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431

I am having a hard time understanding whybelieve cardRequest is the primary culprit in this issue. It is the record object.

Why does my save function will not save and create a record of the page I am trying to save. If anyone has an Idea or critique of this function please feel free to leave your responses. Thank you in advance.?

public PageReference Save() {
            
            //cardRequest.Staff_Member__c = staffMember.Name;
            
            //cardRequest.Requestor__c = requestor == null ? staffMember.Name : requestor.Name;
            
            System.SavePoint sp = Database.setSavepoint();
            
            PageReference ret;
            
            try {
                
                if (cardRequest.ID != NULL) {
                    
                    stdController.save();
                    
                    ret = new PageReference('/' + Business_Card_Request__c.getSObjectType().getDescribe().getKeyPrefix());
                    
                    ret.setRedirect(true);
                    
                }
                
                else {
                    
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Object is NULL*'));
                    
                    isSaveSuccessful = false;
                    
                }
                
            }
            
            catch (System.DMLException ex) {
                
                Database.rollback(sp);
                
                System.Debug(ex);
                
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,ex.getMessage()));
                
                isSaveSuccessful = false;
                
            }
            
            return ret;
            
        }

Also cardRequest is the primary culprit in this. It is the record object.

I am having a hard time understanding why my save function will not save and create a record of the page I am trying to save. If anyone has an Idea or critique of this function please feel free to leave your responses. Thank you in advance.

public PageReference Save() {
            
            //cardRequest.Staff_Member__c = staffMember.Name;
            
            //cardRequest.Requestor__c = requestor == null ? staffMember.Name : requestor.Name;
            
            System.SavePoint sp = Database.setSavepoint();
            
            PageReference ret;
            
            try {
                
                if (cardRequest.ID != NULL) {
                    
                    stdController.save();
                    
                    ret = new PageReference('/' + Business_Card_Request__c.getSObjectType().getDescribe().getKeyPrefix());
                    
                    ret.setRedirect(true);
                    
                }
                
                else {
                    
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Object is NULL*'));
                    
                    isSaveSuccessful = false;
                    
                }
                
            }
            
            catch (System.DMLException ex) {
                
                Database.rollback(sp);
                
                System.Debug(ex);
                
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,ex.getMessage()));
                
                isSaveSuccessful = false;
                
            }
            
            return ret;
            
        }

Also cardRequest is the primary culprit in this. It is the record object.

I believe cardRequest is the primary culprit in this issue. It is the record object.

Why does my save function not save and create a record of the page I am trying to save?

public PageReference Save() {
    System.SavePoint sp = Database.setSavepoint();
    PageReference ret;
    try {
        if (cardRequest.ID != NULL) {
            stdController.save();
            ret = new PageReference('/' + Business_Card_Request__c.getSObjectType().getDescribe().getKeyPrefix());
            ret.setRedirect(true);
        }
        else {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Object is NULL*'));
            isSaveSuccessful = false;
        }
    }
    catch (System.DMLException ex) {
        Database.rollback(sp);
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,ex.getMessage()));
        isSaveSuccessful = false;
    }
    return ret;
}
Source Link

Custom Save function for a Button

I am having a hard time understanding why my save function will not save and create a record of the page I am trying to save. If anyone has an Idea or critique of this function please feel free to leave your responses. Thank you in advance.

public PageReference Save() {
            
            //cardRequest.Staff_Member__c = staffMember.Name;
            
            //cardRequest.Requestor__c = requestor == null ? staffMember.Name : requestor.Name;
            
            System.SavePoint sp = Database.setSavepoint();
            
            PageReference ret;
            
            try {
                
                if (cardRequest.ID != NULL) {
                    
                    stdController.save();
                    
                    ret = new PageReference('/' + Business_Card_Request__c.getSObjectType().getDescribe().getKeyPrefix());
                    
                    ret.setRedirect(true);
                    
                }
                
                else {
                    
                    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Object is NULL*'));
                    
                    isSaveSuccessful = false;
                    
                }
                
            }
            
            catch (System.DMLException ex) {
                
                Database.rollback(sp);
                
                System.Debug(ex);
                
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,ex.getMessage()));
                
                isSaveSuccessful = false;
                
            }
            
            return ret;
            
        }

Also cardRequest is the primary culprit in this. It is the record object.