• Raju kanoperi
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 11
    Replies
I have a question i have 3 fields like  m2,m3,m4 .  m3 depend on m2 field and m4 depend on m3 field like a dependent picklist. These 3 fields are mandatory ok . but one profile user not visible to M4 field initially after saving the record then only user able to see M4 field.

Thanks..
Apex class:
global class AhHandlingEmailservice implements Messaging.InboundEmailHandler {
    global Messaging.Inboundemailresult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        List<DY_Proposal_Attachment__c> proposalList = new List<DY_Proposal_Attachment__c>();
        List<Attachment> attList = new List<Attachment>();
        List<Error_Log__c> errorlogList=new List<Error_Log__c>();
        Map<String,Blob> AttachmentBody = new Map<String,Blob>();
        Set<Integer> proposalIdSet = new Set<Integer>();
        List<Integer> ProposalidsList=new List<Integer>();
        Map<Integer,String> Messagemap= new Map<Integer,String>();
        List<Id> SuccessIdsList= new List<Id>();
           
        try
        {
            for(Messaging.Inboundemail.Binaryattachment bAttachment: email.binaryAttachments){
                string fileName=bAttachment.fileName;
                  if(fileName.lastindexOf('_')!=-1 && fileName.endswith('.pdf')) {
                    Integer propId= integer.valueof(fileName.substring(fileName.indexOf('_')+1,fileName.indexOf('.pdf')));
                      ProposalidsList.add(propId);
                 }
                                
                }
            
         List<DY_Proposal_Attachment__c> dyproposal= new List<DY_Proposal_Attachment__c>([Select id,name,ProposalPDFID__c From DY_Proposal_Attachment__c where ProposalPDFID__c IN:ProposalidsList]);
         
         for(DY_Proposal_Attachment__c dypa:dyproposal){
            Integer propId= integer.valueOf(dypa.ProposalPDFID__c);
              proposalIdSet.add(propId);
         }  
         for( Messaging.Inboundemail.Binaryattachment bAttachment: email.binaryAttachments){
                 string fileName=bAttachment.fileName;
                 Blob body=bAttachment.body;
                 String Message='';
                 Integer propId=integer.valueof(fileName.substring(fileName.indexof('_')+1,filename.indexof('.pdf')));
             if(fileName.lastindexOf('_')!=-1 && fileName.endswith('.pdf')) {  
                 String name = fileName.substring(0,fileName.indexOf('.pdf'));
             if(!proposalIdSet.contains(propId)){
                      DY_Proposal_Attachment__c dypa = new DY_Proposal_Attachment__c();
                      dypa.Name = name;
                      dypa.ProposalPDFID__c = propId;
                      AttachmentBody.put(dypa.Name,body);
                      proposalList.add(dypa);
                     }else{
                       Message='Duplicate Record can not Insert';
                       Messagemap.put(propId,Message);
                                   
                    }
                   
                   }else{
                        Message='File Name should be a proper format';
                        Messagemap.put(propId,Message);  
                   }
                   
                  }  
            
           if(proposalList.size()>0){
                insert proposalList;
               
            }
              
            if(proposalList.size()>0){
              
              for(DY_Proposal_Attachment__c proAtt:proposalList){
                     Attachment attachment = new Attachment();
                     attachment.ParentId = proAtt.Id;
                     attachment.Body = AttachmentBody.get(proAtt.name);
                     attachment.Name = proAtt.name +'.pdf';
                     attList.add(attachment);
              }
            }
            
            if(attList.size()>0){
                             
             Database.saveResult[] attRecs = Database.insert(attList,false);
             for(Database.SaveResult sr:attRecs){
             if (sr.isSuccess()) {
                 SuccessIdsList.add(sr.getId());
                
             }
            
              }
                   
                }
            
             if(SuccessIdsList.size() == email.binaryAttachments.size()){
                 result.message = 'Your record(s) Successfully Inserted';    
             }
             else{
                  String myCustomMsg = 'The following attachment(s) insertion got failed.';
                
                 for(Integer aProposalId : Messagemap.keySet()){
                     myCustomMsg += 'The Attachment with the ProposalId '+aProposalId+' insertion got failed due to '+Messagemap.get(aProposalId)+' \n';   
                 }
                 result.message = myCustomMsg;
             }  
            
         }catch(Exception e){
              result.success = False;
              System.debug('Exception: '+e.getMessage());
              result.message = 'Failed to insert an attachment. '+e.getMessage();
              createErrorRecord(e.getMessage());
         }
              return result;
                  
         }
      
      public static void createErrorRecord(string exceptionMessage){
              system.debug('---ErrorLog----');
             Error_Log__c newErrorRecord = new  Error_Log__c();
                 newErrorRecord.Your_comments__c = exceptionMessage;
                // newErrorRecord.Name = fileName.substring(0,fileName.indexOf('.pdf'));
                 newErrorRecord.Name =  'Email Services Error Insert';
                 newErrorRecord.Processed_date__c = system.now();
                 newErrorRecord.Status__c = 'New';
                 newErrorRecord.Source__c = 'CorSales-StopLoss';
                 newErrorRecord.Object__c = 'DY Proposal';
                 newErrorRecord.Error_Type__c = 'Email Services';
                 Database.insert(newErrorRecord,false);
   }
    
  }


Test class:

@isTest(SeeAllData=False)

 public class AhHandlingEmailserviceTest{
   private static testmethod void Emailattachmentinsert(){

// create DY proposal attachment record

    DY_Proposal_Attachment__c Dyatt= new DY_Proposal_Attachment__c();
         Dyatt.name='Sample_786';
         Dyatt.ProposalPDFID__c= 786;
         Dyatt.Proposal_attached_successfully__c=true;
         insert Dyatt;
 // DY_Proposal_Attachment__c dyp=[select id,name,ProposalPDFID__c From DY_Proposal_Attachment__c where ProposalPDFID__c=:Dyatt.Id];
     Messaging.InboundEmail email = new Messaging.InboundEmail();
     Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
   
        email.subject = 'Test Proposal';
        email.fromname = 'sudhakar';
        env.fromAddress = 'rcomext.com';
     Error_Log__c newErrorRecord = new  Error_Log__c();
                 newErrorRecord.Name = 'Email Services Error Insert';
                 newErrorRecord.Processed_date__c = system.now();
                 newErrorRecord.Status__c = 'New';
                 newErrorRecord.Source__c = 'CorSales-StopLoss';
                 newErrorRecord.Object__c = 'DY Proposal';
                 newErrorRecord.Error_Type__c = 'Email Services';
                 Database.insert(newErrorRecord,false);
      Messaging.Inboundemail.Binaryattachment attachment = new Messaging.Inboundemail.Binaryattachment();
                 attachment.Body = Blob.toPdf('Sample PDF Text');
                 attachment.fileName = 'Sample_786.pdf';
      
      email.binaryAttachments = new Messaging.Inboundemail.Binaryattachment[]{attachment};
      
          AhHandlingEmailservice emailHandler = new AhHandlingEmailservice();
      Test.startTest();
      Messaging.Inboundemailresult result = emailHandler.handleInboundEmail(email, env);
            system.assert(result.success,'InbountEmailResult returnd a Failure message');
      Test.stopTest();
}

}

 
trigger DealProfitCenterUpdate on Quote_Option__c (after insert,after update) {
     List<Quote_Option__c> QpList = new List<Quote_Option__c>();
     Set<String> RetridSet = new Set<String>();
     Map<String,String> ProfitcenterMap = new Map<String,String>();
     List<Opportunity> OppList = new List<Opportunity>();
 
          for(Quote_Option__c Qoop: Trigger.new){
             RetridSet.add(Qoop.ReiTreatyId__c);
             QpList.add(Qoop);
               
       }

List<DY_Profit_Center__c> Dy = new List<DY_Profit_Center__c>([SELECT id,ReiTreatyId__c,DY_Profit_Center__c,DY_Profit_Center_Description__c FROM DY_Profit_Center__c WHERE ReiTreatyId__c IN:RetridSet]);

          for(DY_Profit_Center__c aProfitcenter:Dy){
              ProfitcenterMap.put(aProfitcenter.ReiTreatyId__c,aProfitcenter.DY_Profit_Center__c);
       
        }
    
          for(Quote_Option__c aQuoteOption:QpList){
             if(ProfitcenterMap.ContainsKey(aQuoteOption.ReiTreatyId__c)){
                 if(aQuoteOption.StopLoss_Deal__c !=NULL){
                    Opportunity Opp=new Opportunity(Id = aQuoteOption.StopLoss_Deal__c);
                      Opp.PCL_5__C = ProfitcenterMap.get(aQuoteOption.ReiTreatyId__c);
                         OppList.add(opp);
          
                  }
                              
                }
            
              }
            
            if(OppList.size()>0){
            Database.update(OppList,False);
                        
            
            }
        }
global class OpportunityAttachmentsEmailHandler implements Messaging.Inboundemailhandler {
  global Messaging.Inboundemailresult handleInboundEmail (Messaging.Inboundemail email, Messaging.Inboundenvelope envelope)
  {
    Messaging.Inboundemailresult result = new Messaging.Inboundemailresult();
    List<Opportunity> oppsToUpdate = new List<Opportunity>();
    List<Attachment> attachmentsToInser = new List<Attachment>();
    try
    {
      for(Messaging.Inboundemail.Binaryattachment bAttachment: email.binaryAttachments)
      {
        string fileName = bAttachment.fileName;
        System.debug('FileName: '+fileName);
        if(fileName.lastindexOf('_')!=-1 && fileName.endswith('.pdf')) {          
          string recordId = fileName.substring(fileName.lastindexOf('_') + 1, fileName.indexOf('.pdf'));
          system.debug('ProposalID: ' + recordId);
          Integer temp = integer.ValueOf(recordId);
          List<Opportunity> oppList = [select ID from Opportunity where ProposalPDFID__c = :temp];
          if (oppList.size() > 0)
          {
            for(Opportunity theOpp : oppList) {
              System.debug('Opportunity Id: '+theOpp.id);

              Attachment proposalAtt = new Attachment();
              proposalAtt.Name = bAttachment.fileName;
              proposalAtt.Body = bAttachment.body;
              proposalAtt.ParentId = theOpp.ID;
              attachmentsToInser.add(proposalAtt);

              theOpp.Have_attachment__c = true;
              theOpp.Attachment_id__c = proposalAtt.id;
              oppsToUpdate.add(theOpp);
            }
            try
            {
              insert attachmentsToInser;
              update oppsToUpdate;
            }
            catch(Exception ex)
            {
              continue;
            }
          }else{
            try{
              Unattached_Proposals__c unattachedProposal = new Unattached_Proposals__c();
              unattachedProposal.ProposalPDFID__c = temp;
              insert unattachedProposal;
              
              Attachment proposalAtt = new Attachment();
              proposalAtt.Name = bAttachment.fileName;
              proposalAtt.Body = bAttachment.body;
              proposalAtt.ParentId = unattachedProposal.ID;
              insert proposalAtt;
              
              
            }
            catch(Exception ex)
            {
              continue;
            }
          }
        }
      }
      result.success = true;
    }
    catch(Exception e)
    {
      result.success = false;
      System.debug('Exception: '+e.getMessage());
      result.message = 'Failed to insert an attachment. '+e.getMessage()+' stack trace: '+e.getStackTraceString();
    }
    
    return result;
      
  }
Hi , in visualforce page  subject , mobile, email fields are present. in email field what ever the mail id given that mail has to go that perticular mail after clicking the submit button  please provide code .
for example in vf page email field= abc@co.in given after clicking the submit button that mail has sent to abc@co.in


thanks
raju


 
i have a question. i have two applications like A and B. user U1 can see U2 AND U3 user records and U2 can see U1 records and U3 can see U1 records but U2 and U3 has same profile. U2 user can not see U3  and U3 user can not see U2 records how to achive this. help me .


A      B
U1    U2,U3


Thanks
Raju
how to build a search like google serach in visualforce page. for example i am serching something like "salesforce materials" in visualforce page dirctly go to that page ..please help me ..



thanks
Hi, i have a question in visualforce page hide the page block section.  i have two users with same profile one user can see  and another user can't see the pageblock section.



Thank you 
Hi, i have a question i want to display records based on pick list value in visualforce page. for ex: in the picklist if i select account display account trecords and if i select contact display contact records like that send me the code snippest thank you fr advance
how to build a search like google serach in visualforce page. for example i am serching something like "salesforce materials" in visualforce page dirctly go to that page ..please help me ..



thanks
I have a question i have 3 fields like  m2,m3,m4 .  m3 depend on m2 field and m4 depend on m3 field like a dependent picklist. These 3 fields are mandatory ok . but one profile user not visible to M4 field initially after saving the record then only user able to see M4 field.

Thanks..
Apex class:
global class AhHandlingEmailservice implements Messaging.InboundEmailHandler {
    global Messaging.Inboundemailresult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
        List<DY_Proposal_Attachment__c> proposalList = new List<DY_Proposal_Attachment__c>();
        List<Attachment> attList = new List<Attachment>();
        List<Error_Log__c> errorlogList=new List<Error_Log__c>();
        Map<String,Blob> AttachmentBody = new Map<String,Blob>();
        Set<Integer> proposalIdSet = new Set<Integer>();
        List<Integer> ProposalidsList=new List<Integer>();
        Map<Integer,String> Messagemap= new Map<Integer,String>();
        List<Id> SuccessIdsList= new List<Id>();
           
        try
        {
            for(Messaging.Inboundemail.Binaryattachment bAttachment: email.binaryAttachments){
                string fileName=bAttachment.fileName;
                  if(fileName.lastindexOf('_')!=-1 && fileName.endswith('.pdf')) {
                    Integer propId= integer.valueof(fileName.substring(fileName.indexOf('_')+1,fileName.indexOf('.pdf')));
                      ProposalidsList.add(propId);
                 }
                                
                }
            
         List<DY_Proposal_Attachment__c> dyproposal= new List<DY_Proposal_Attachment__c>([Select id,name,ProposalPDFID__c From DY_Proposal_Attachment__c where ProposalPDFID__c IN:ProposalidsList]);
         
         for(DY_Proposal_Attachment__c dypa:dyproposal){
            Integer propId= integer.valueOf(dypa.ProposalPDFID__c);
              proposalIdSet.add(propId);
         }  
         for( Messaging.Inboundemail.Binaryattachment bAttachment: email.binaryAttachments){
                 string fileName=bAttachment.fileName;
                 Blob body=bAttachment.body;
                 String Message='';
                 Integer propId=integer.valueof(fileName.substring(fileName.indexof('_')+1,filename.indexof('.pdf')));
             if(fileName.lastindexOf('_')!=-1 && fileName.endswith('.pdf')) {  
                 String name = fileName.substring(0,fileName.indexOf('.pdf'));
             if(!proposalIdSet.contains(propId)){
                      DY_Proposal_Attachment__c dypa = new DY_Proposal_Attachment__c();
                      dypa.Name = name;
                      dypa.ProposalPDFID__c = propId;
                      AttachmentBody.put(dypa.Name,body);
                      proposalList.add(dypa);
                     }else{
                       Message='Duplicate Record can not Insert';
                       Messagemap.put(propId,Message);
                                   
                    }
                   
                   }else{
                        Message='File Name should be a proper format';
                        Messagemap.put(propId,Message);  
                   }
                   
                  }  
            
           if(proposalList.size()>0){
                insert proposalList;
               
            }
              
            if(proposalList.size()>0){
              
              for(DY_Proposal_Attachment__c proAtt:proposalList){
                     Attachment attachment = new Attachment();
                     attachment.ParentId = proAtt.Id;
                     attachment.Body = AttachmentBody.get(proAtt.name);
                     attachment.Name = proAtt.name +'.pdf';
                     attList.add(attachment);
              }
            }
            
            if(attList.size()>0){
                             
             Database.saveResult[] attRecs = Database.insert(attList,false);
             for(Database.SaveResult sr:attRecs){
             if (sr.isSuccess()) {
                 SuccessIdsList.add(sr.getId());
                
             }
            
              }
                   
                }
            
             if(SuccessIdsList.size() == email.binaryAttachments.size()){
                 result.message = 'Your record(s) Successfully Inserted';    
             }
             else{
                  String myCustomMsg = 'The following attachment(s) insertion got failed.';
                
                 for(Integer aProposalId : Messagemap.keySet()){
                     myCustomMsg += 'The Attachment with the ProposalId '+aProposalId+' insertion got failed due to '+Messagemap.get(aProposalId)+' \n';   
                 }
                 result.message = myCustomMsg;
             }  
            
         }catch(Exception e){
              result.success = False;
              System.debug('Exception: '+e.getMessage());
              result.message = 'Failed to insert an attachment. '+e.getMessage();
              createErrorRecord(e.getMessage());
         }
              return result;
                  
         }
      
      public static void createErrorRecord(string exceptionMessage){
              system.debug('---ErrorLog----');
             Error_Log__c newErrorRecord = new  Error_Log__c();
                 newErrorRecord.Your_comments__c = exceptionMessage;
                // newErrorRecord.Name = fileName.substring(0,fileName.indexOf('.pdf'));
                 newErrorRecord.Name =  'Email Services Error Insert';
                 newErrorRecord.Processed_date__c = system.now();
                 newErrorRecord.Status__c = 'New';
                 newErrorRecord.Source__c = 'CorSales-StopLoss';
                 newErrorRecord.Object__c = 'DY Proposal';
                 newErrorRecord.Error_Type__c = 'Email Services';
                 Database.insert(newErrorRecord,false);
   }
    
  }


Test class:

@isTest(SeeAllData=False)

 public class AhHandlingEmailserviceTest{
   private static testmethod void Emailattachmentinsert(){

// create DY proposal attachment record

    DY_Proposal_Attachment__c Dyatt= new DY_Proposal_Attachment__c();
         Dyatt.name='Sample_786';
         Dyatt.ProposalPDFID__c= 786;
         Dyatt.Proposal_attached_successfully__c=true;
         insert Dyatt;
 // DY_Proposal_Attachment__c dyp=[select id,name,ProposalPDFID__c From DY_Proposal_Attachment__c where ProposalPDFID__c=:Dyatt.Id];
     Messaging.InboundEmail email = new Messaging.InboundEmail();
     Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
   
        email.subject = 'Test Proposal';
        email.fromname = 'sudhakar';
        env.fromAddress = 'rcomext.com';
     Error_Log__c newErrorRecord = new  Error_Log__c();
                 newErrorRecord.Name = 'Email Services Error Insert';
                 newErrorRecord.Processed_date__c = system.now();
                 newErrorRecord.Status__c = 'New';
                 newErrorRecord.Source__c = 'CorSales-StopLoss';
                 newErrorRecord.Object__c = 'DY Proposal';
                 newErrorRecord.Error_Type__c = 'Email Services';
                 Database.insert(newErrorRecord,false);
      Messaging.Inboundemail.Binaryattachment attachment = new Messaging.Inboundemail.Binaryattachment();
                 attachment.Body = Blob.toPdf('Sample PDF Text');
                 attachment.fileName = 'Sample_786.pdf';
      
      email.binaryAttachments = new Messaging.Inboundemail.Binaryattachment[]{attachment};
      
          AhHandlingEmailservice emailHandler = new AhHandlingEmailservice();
      Test.startTest();
      Messaging.Inboundemailresult result = emailHandler.handleInboundEmail(email, env);
            system.assert(result.success,'InbountEmailResult returnd a Failure message');
      Test.stopTest();
}

}

 
Hi , in visualforce page  subject , mobile, email fields are present. in email field what ever the mail id given that mail has to go that perticular mail after clicking the submit button  please provide code .
for example in vf page email field= abc@co.in given after clicking the submit button that mail has sent to abc@co.in


thanks
raju


 
i have a question. i have two applications like A and B. user U1 can see U2 AND U3 user records and U2 can see U1 records and U3 can see U1 records but U2 and U3 has same profile. U2 user can not see U3  and U3 user can not see U2 records how to achive this. help me .


A      B
U1    U2,U3


Thanks
Raju
how to build a search like google serach in visualforce page. for example i am serching something like "salesforce materials" in visualforce page dirctly go to that page ..please help me ..



thanks
Hi, i have a question i want to display records based on pick list value in visualforce page. for ex: in the picklist if i select account display account trecords and if i select contact display contact records like that send me the code snippest thank you fr advance