• Aparna Bochare 6
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am trying to just add a sucess message when the user enters a case, I am obviously new to Apex and can't figure out how to do this. When I put this in I get the following error message on the success - ​Keep getting the error message - Non-void method might not return a value or might have statement after a return statement.

 // Insert the case
                INSERT c;
                if (objAttachment.Body != null) {
                    // Insert attachment if exists
                      objAttachment.ParentId = c.Id;
                    insert objAttachment;
                }
                
                 ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.CONFIRM, 'Success!'));
            } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
        }
    }

Thank you very much for any information on how to do this.