• ST_SFDC
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Associate Technology
  • Synechron

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

    // method submit the case
   public PageReference submitCase() {
     
            try {
              
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);
              
                c.SuppliedName = username;
                c.SuppliedEmail = useremail;
                c.Market__c = market;
                c.Boss_Region__c = region;
                c.Case_CC_List__c = CCuser; 
                ccAddresses = CCuser.split(',');  // capture multiple CCed email list
               
               
              
                if(productType=='Manage'){
                    Id mngRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Manage').getRecordTypeId();
                    c.RecordTypeId = mngRcdTypeId;   // RT = Manage
                   
               }
               else if(ReqType =='Salesforce Support' || productTypeRadia=='SalesForce Related Issue') {
                   Id sfsRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Salesforce Support').getRecordTypeId();
                   c.RecordTypeId = sfsRcdTypeId; // RT= SF Support
                }
               
              else if(ReqType =='New Feature Request'){
                  Id enblmtRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Enablement').getRecordTypeId();
                  c.RecordTypeId = enblmtRcdTypeId;   // RT = Enablement
              }
                           
                if((productType=='XBP' && (productTypeRadia=='Radia Related Issue' ||productTypeRadia=='Business Question / Help'))||productType=='Slack'){
                  
                    sendEmail(); // send email
                      
                }
                INSERT c;
                    
                      //Attachment Start
               
                    attachment.OwnerId = UserInfo.getUserId();
                    attachment.ParentId = c.id; // the record the file is attached to
                    attachment.IsPrivate = false;
                system.debug('starting try block ++++++++++++++');
                    try {
                          insert attachment;
                        } catch (DMLException e) {
                      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
                     // return null;
                    }
                system.debug('Ending try block ++++++++++++++');
                             
                           
                   PageReference redirectPage = Page.thanks;
                   redirectPage.setRedirect(true);
                   return redirectPage;                                                                        
                             
            } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
      
        }
   
}

    // method submit the case
   public PageReference submitCase() {
     
            try {
              
                // Specify DML options to ensure the assignment rules are executed
                Database.DMLOptions dmlOpts = new Database.DMLOptions();
                dmlOpts.assignmentRuleHeader.useDefaultRule = true;
                c.setOptions(dmlOpts);
              
                c.SuppliedName = username;
                c.SuppliedEmail = useremail;
                c.Market__c = market;
                c.Boss_Region__c = region;
                c.Case_CC_List__c = CCuser; 
                ccAddresses = CCuser.split(',');  // capture multiple CCed email list
               
               
              
                if(productType=='Manage'){
                    Id mngRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Manage').getRecordTypeId();
                    c.RecordTypeId = mngRcdTypeId;   // RT = Manage
                   
               }
               else if(ReqType =='Salesforce Support' || productTypeRadia=='SalesForce Related Issue') {
                   Id sfsRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Salesforce Support').getRecordTypeId();
                   c.RecordTypeId = sfsRcdTypeId; // RT= SF Support
                }
               
              else if(ReqType =='New Feature Request'){
                  Id enblmtRcdTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Enablement').getRecordTypeId();
                  c.RecordTypeId = enblmtRcdTypeId;   // RT = Enablement
              }
                           
                if((productType=='XBP' && (productTypeRadia=='Radia Related Issue' ||productTypeRadia=='Business Question / Help'))||productType=='Slack'){
                  
                    sendEmail(); // send email
                      
                }
                INSERT c;
                    
                      //Attachment Start
               
                    attachment.OwnerId = UserInfo.getUserId();
                    attachment.ParentId = c.id; // the record the file is attached to
                    attachment.IsPrivate = false;
                system.debug('starting try block ++++++++++++++');
                    try {
                          insert attachment;
                        } catch (DMLException e) {
                      ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
                     // return null;
                    }
                system.debug('Ending try block ++++++++++++++');
                             
                           
                   PageReference redirectPage = Page.thanks;
                   redirectPage.setRedirect(true);
                   return redirectPage;                                                                        
                             
            } catch (Exception e) {
                ApexPages.addMessages(e);
                return null;
            }
      
        }
   
}