• Anu Singh 40
  • NEWBIE
  • 20 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 3
    Replies
Hi All

Can Anyone tell me maximum nuber of lookup relations on an object.
Are there 25 or 38 or 40?
Thanks in Advance
Hi All
I have to write a test class for following class. I wrote  test class for my apex class but it only giving 35% coverage.
 can anyone help me
Thanks in Advance
global class Handle_Incoming_Email_Forwarding implements Messaging.InboundEmailHandler {
    
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, 
                                                           Messaging.InboundEnvelope env)
    {
String myPlainText= '';
        String toAdd=(String.valueOf(email.toAddresses).contains('(') && String.valueOf(email.toAddresses).contains(')')) ? String.valueOf(email.toAddresses).replace('(','').replace(')','') : String.valueOf(email.toAddresses);
                String ccAdd=email.ccAddresses == NULL ? '' : (String.valueOf(email.ccAddresses).contains('(') && String.valueOf(email.ccAddresses).contains(')'))? String.valueOf(email.ccAddresses).replace ('(','').replace(')','') : String.valueOf(email.ccAddresses);
                myPlainText = 'To: '+toAdd+'\n'+ 'CC: '+ccAdd+ '\n'+ 'From Addresses: '+String.valueOf(email.fromAddress).replace('(','').replace(')','')+ '\n'+ 'Subject: '+email.subject+ '\n'+email.plainTextBody;
 
        Task[] newTask = new Task[0];
        Task[] newTask1 = new task[0];
        Task[] newTask2 = new task[0];
        
        try {       
 Id UserId= [SELECT Id, Name, Email FROM User WHERE Email =:email.toAddresses LIMIT 1].Id;
                for(Lead obj: [SELECT Id, Name, Email  FROM Lead WHERE Email = :email.fromAddress]){
                    task t=new Task(
                                     ActivityDate = System.today(),
                        Description =  myPlainText,                          
                                          Priority = 'Normal',
                                          Status = 'Completed',
                                          Subject = 'Email: '+email.subject,
                                          IsReminderSet = true,
                                          TaskSubtype='Email',
                                          RecurrenceStartDateOnly = System.today(),
                        
                                          WhoId =  obj.ID);
                                         
                    insert t;
                    EmailMessage e = new EmailMessage();
                    e.ActivityId=t.id;
                    
                    
                    
                    
                    newTask2.add(new Task(                         
                                      Priority = 'Normal',
                                      Status = 'Inbound Email',
                                      Subject = 'Reply',
                                      IsReminderSet = true,
                                      Description =  myPlainText,
                                     ActivityDate = System.today()+7,
                                      OwnerId= UserId,
                                      //ActivityDate = System.today().addDays(7),
                                      RecurrenceStartDateOnly = System.today(),
                                      WhoId =  obj.ID                   
                                     )); 
                }
 Id UserId= [SELECT Id, Name, Email FROM User WHERE Email =:email.toAddresses LIMIT 1].Id;
                for(Lead obj: [SELECT Id, Name, Email  FROM Lead WHERE Email = :email.fromAddress]){
                    task t=new Task(
                                     ActivityDate = System.today(),
                        Description =  myPlainText,                          
                                          Priority = 'Normal',
                                          Status = 'Completed',
                                          Subject = 'Email: '+email.subject,
                                          IsReminderSet = true,
                                          TaskSubtype='Email',
                                          RecurrenceStartDateOnly = System.today(),
                        
                                          WhoId =  obj.ID);
                                         
                    insert t;
                    EmailMessage e = new EmailMessage();
                    e.ActivityId=t.id;
                    
                    
                    
                    
                    newTask2.add(new Task(                         
                                      Priority = 'Normal',
                                      Status = 'Inbound Email',
                                      Subject = 'Reply',
                                      IsReminderSet = true,
                                      Description =  myPlainText,
                                     ActivityDate = System.today()+7,
                                      OwnerId= UserId,
                                      //ActivityDate = System.today().addDays(7),
                                      RecurrenceStartDateOnly = System.today(),
                                      WhoId =  obj.ID                   
                                     )); 
                }


test class:
@istest
public class TEST_Handle_Incoming_Email_Forwading {   
   static testMethod void TestinBoundEmail()
   {
         String contactEmail = 'contactEmail@test.com';
      
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
 email.subject = 'Create Contact';
      email.fromAddress = contactEmail;
      email.ccAddresses = (new String[] { 'person2@salesforce.com', 'person2@salesforce.com' });
      email.fromName='test';
      email.htmlBody='this is Html Body for email';
      email.plainTextBody = 'email body';
      email.toAddresses=(new String[] { 'test@salesforce.com', 'test2@salesforce.com' });
      email.replyTo='reply@email.com';
      Messaging.InboundEmail.BinaryAttachment attachment = new Messaging.InboundEmail.BinaryAttachment();
      attachment.body = blob.valueOf('my attachment text');
      attachment.fileName = 'textfileone.txt';
      attachment.mimeTypeSubType = 'text/plain';
       
      email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment };
          
    Handle_Incoming_Email_Forwarding testEmail = new Handle_Incoming_Email_Forwarding();
     testEmail.handleInboundEmail(email, env);
   }
}

for loop is not coverd by this test class. What else I can write to cover this class
Hi All,
I am trying to display apex catch exception error message in lightning component. I have tried below in code. but it didn't work.
Apex code:
try{
                    database.delete(opp.AccountId);    
                    database.delete(opp,false);
                    wrapobj.state='Deleted';  
                    System.debug('opportunity and Account  deleted !! ');
                    }catch(Exception e){
                        System.debug('Error Msg'+e.getMessage());
                         wrapobj.state='Error occured';
                        //throw new AuraHandledException(e.getMessage()); 
                      
                        wrapobj.errorMsg= e.getMessage();
                    }
                }
Controller
else if(result=='Error occured'){
                   console.log('Inside error block');
                     // console.log(Component.get('v.ShowErrorMsg'));
                    Component.set('v.ShowErrorMsg',response.getReturnValue().errorMsg);
                   console.log(Component.get('v.ShowErrorMsg'));
                    console.log('system error msg',response.getReturnValue().errorMsg);
                     component.set('v.displayedSection',false);
                      component.set('v.isShowError',true);
                    //console.log(error);
                }
It enter in block but error msg is not setting in attribute ShowErrorMsg.

can Anyone  help me to solve this
Thanks in Advance
Hi All,
I want to know Is it possible to see the mapping custom field of lead to contact,opportunity and contact.
Where can I see this mapping field In backround.where it will be stored apart from the map to lead field.


Thanks 
Hi All,
I want to bind values from two aura iteration.I have three fields values Opportunity, Contact and Account 
i have  custom lead fields In lead fields like 
SIC Code
Number of location
Current Generators
I want to match lead SIC code to Account SIC code.
Current Generators to opportnity current generators.All fields are dynamic 
How can I bind the values . Can Anyone help me with this

Thanks 
Hi All
I  m new to salesforce I want to select different values from a picklist where picklist is in aura iteration. It shows Only one selected value in all picklist from aura iteration.
here is the code
 <aura:iteration items="{!v.Leadoptions}" var="fieldname">
     <tr> <td class="slds-line-height_reset">   
        <div>{!fieldname}</div> 
                 </td>
               <td class="slds-line-height_reset">
                 <lightning:select name="opportunity"  label="" aura:id="onjId" value="{!v.OppselectedValue}" onchange="{!c.changeAction}">
                 <option value="">None</option>
                <aura:iteration items="{!v.Opportunityoptions}" var="oppname">
                    <option value="{!oppname}" text="{!oppname}"/>  
                   </aura:iteration>
                      </lightning:select>
               </td>
                      
              </tr>  
               </aura:iteration>    User-added image
Hi ,
I am new to lightning. I have a lightning select for showing options here option are list of contact.
<div>
                   Contact: <lightning:select name="con" class="slds-combobox_container slds-size_small"  
                                              aura:id="con" value="{!v.selectedContact}" onchange="{!c.changeAction}" >
                       <option value="">choose one...</option>
                 <aura:iteration items="{!v.conOption}" var="opt">
                     <option text="{!opt.LastName}" value="{!opt.id}" selected="{!opt.selected}" /> 
               </aura:iteration>
               </lightning:select>
                      </div>    

And I have a attribute 
<aura:attribute name="selectedContact" type="String" />

I want selectedContact show con.Id But When I am geeting the value in a function using var selectedCon=component.get('v.selectedContact');
it shows Name of contact I want Id of Contact
How Can I do that. Please help
Thankyou in Advance
Hi All

I need to know How to copy one custom object field in another custom object field dynamically in lighntning?
Like we do whenever we match the field  by Map to lead button in lead object if we want to map custom field. If we want opportunity Account and Contact data is saved in  back to lead then how can we do this dynamically?
If a custom field is created on Account  so we have to create a cutom field on lead. then how can we match the field by code.

 
Hi All,
I need to call Apex class in Account detail page on button click in lightning. How can I do it.
Hi All
I have to write a test class for following class. I wrote  test class for my apex class but it only giving 35% coverage.
 can anyone help me
Thanks in Advance
global class Handle_Incoming_Email_Forwarding implements Messaging.InboundEmailHandler {
    
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, 
                                                           Messaging.InboundEnvelope env)
    {
String myPlainText= '';
        String toAdd=(String.valueOf(email.toAddresses).contains('(') && String.valueOf(email.toAddresses).contains(')')) ? String.valueOf(email.toAddresses).replace('(','').replace(')','') : String.valueOf(email.toAddresses);
                String ccAdd=email.ccAddresses == NULL ? '' : (String.valueOf(email.ccAddresses).contains('(') && String.valueOf(email.ccAddresses).contains(')'))? String.valueOf(email.ccAddresses).replace ('(','').replace(')','') : String.valueOf(email.ccAddresses);
                myPlainText = 'To: '+toAdd+'\n'+ 'CC: '+ccAdd+ '\n'+ 'From Addresses: '+String.valueOf(email.fromAddress).replace('(','').replace(')','')+ '\n'+ 'Subject: '+email.subject+ '\n'+email.plainTextBody;
 
        Task[] newTask = new Task[0];
        Task[] newTask1 = new task[0];
        Task[] newTask2 = new task[0];
        
        try {       
 Id UserId= [SELECT Id, Name, Email FROM User WHERE Email =:email.toAddresses LIMIT 1].Id;
                for(Lead obj: [SELECT Id, Name, Email  FROM Lead WHERE Email = :email.fromAddress]){
                    task t=new Task(
                                     ActivityDate = System.today(),
                        Description =  myPlainText,                          
                                          Priority = 'Normal',
                                          Status = 'Completed',
                                          Subject = 'Email: '+email.subject,
                                          IsReminderSet = true,
                                          TaskSubtype='Email',
                                          RecurrenceStartDateOnly = System.today(),
                        
                                          WhoId =  obj.ID);
                                         
                    insert t;
                    EmailMessage e = new EmailMessage();
                    e.ActivityId=t.id;
                    
                    
                    
                    
                    newTask2.add(new Task(                         
                                      Priority = 'Normal',
                                      Status = 'Inbound Email',
                                      Subject = 'Reply',
                                      IsReminderSet = true,
                                      Description =  myPlainText,
                                     ActivityDate = System.today()+7,
                                      OwnerId= UserId,
                                      //ActivityDate = System.today().addDays(7),
                                      RecurrenceStartDateOnly = System.today(),
                                      WhoId =  obj.ID                   
                                     )); 
                }
 Id UserId= [SELECT Id, Name, Email FROM User WHERE Email =:email.toAddresses LIMIT 1].Id;
                for(Lead obj: [SELECT Id, Name, Email  FROM Lead WHERE Email = :email.fromAddress]){
                    task t=new Task(
                                     ActivityDate = System.today(),
                        Description =  myPlainText,                          
                                          Priority = 'Normal',
                                          Status = 'Completed',
                                          Subject = 'Email: '+email.subject,
                                          IsReminderSet = true,
                                          TaskSubtype='Email',
                                          RecurrenceStartDateOnly = System.today(),
                        
                                          WhoId =  obj.ID);
                                         
                    insert t;
                    EmailMessage e = new EmailMessage();
                    e.ActivityId=t.id;
                    
                    
                    
                    
                    newTask2.add(new Task(                         
                                      Priority = 'Normal',
                                      Status = 'Inbound Email',
                                      Subject = 'Reply',
                                      IsReminderSet = true,
                                      Description =  myPlainText,
                                     ActivityDate = System.today()+7,
                                      OwnerId= UserId,
                                      //ActivityDate = System.today().addDays(7),
                                      RecurrenceStartDateOnly = System.today(),
                                      WhoId =  obj.ID                   
                                     )); 
                }


test class:
@istest
public class TEST_Handle_Incoming_Email_Forwading {   
   static testMethod void TestinBoundEmail()
   {
         String contactEmail = 'contactEmail@test.com';
      
       Messaging.InboundEmail email = new Messaging.InboundEmail() ;
       Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
 email.subject = 'Create Contact';
      email.fromAddress = contactEmail;
      email.ccAddresses = (new String[] { 'person2@salesforce.com', 'person2@salesforce.com' });
      email.fromName='test';
      email.htmlBody='this is Html Body for email';
      email.plainTextBody = 'email body';
      email.toAddresses=(new String[] { 'test@salesforce.com', 'test2@salesforce.com' });
      email.replyTo='reply@email.com';
      Messaging.InboundEmail.BinaryAttachment attachment = new Messaging.InboundEmail.BinaryAttachment();
      attachment.body = blob.valueOf('my attachment text');
      attachment.fileName = 'textfileone.txt';
      attachment.mimeTypeSubType = 'text/plain';
       
      email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment };
          
    Handle_Incoming_Email_Forwarding testEmail = new Handle_Incoming_Email_Forwarding();
     testEmail.handleInboundEmail(email, env);
   }
}

for loop is not coverd by this test class. What else I can write to cover this class
Hi All,
I want to know Is it possible to see the mapping custom field of lead to contact,opportunity and contact.
Where can I see this mapping field In backround.where it will be stored apart from the map to lead field.


Thanks