• Brenda S Finn
  • NEWBIE
  • 115 Points
  • Member since 2014
  • Senior Force.Com Developer
  • OpFocus, Inc.

  • Chatter
    Feed
  • 3
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 31
    Replies
Hello friends
request your help in writing the trigger code. LastName in contact should be unqiue.

apex class code:
=============
public class Prevent
{
   public void Display(Id[] currentrecordId)
   {
          list<Contact> con=[select LastName from Contact where Id=:currentrecordId];
         for(Contact c:con)
          {
                if (con.size()>0)
                   c.LastName.AddError('LastName Already Exists');
          }
      }
}

Trigger Code:
==========
trigger trg_LastName on Contact (before insert,before update)
{
    if (trigger.isBefore)
    {
          if (trigger.isInsert || trigger.isUpdate)
          {
          
                Prevent obj=new Prevent();
          
                 for(Id consid:trigger.NewMap.KeySet())
                 {
                    obj.Display(consid);
                 }
          }
    }
}

When I save the trigger , I get error message as :Error: Compile Error: Method does not exist or incorrect signature: [Prevent].Display(Id) at line 12 column 21

Please let me know how to resolve this or any issue with the apex class code itself..

Regards
Krishna Casukhela
I have this trigger that i created but i am unable to figure out how to get the query out of the for loop, my trigger will run but i know it will hit some governer limits. 

trigger AcceptJobAndCreateEmployee on Candidate_Application__c (after update) {
    
    //This will be the list to add the new candidate
    List<Account> accounts = new List<Account>();

    //Query for the Account Record Types
    List<RecordType> rtypes = [Select name, id FROM RecordType WHERE sObjectType = 'Account' AND IsPersonType = True];
   
    Map<String,String> accountRecordTypes = new Map<String,String>();
        for(RecordType rt: rtypes){
            accountRecordTypes.put(rt.Name,rt.id);
        }
        
    

    for(Candidate_Application__c thisApplication: Trigger.new)
    {
        Candidate_Application__c oldApp = Trigger.oldMap.get(thisApplication.id);
        Boolean AppFalse = oldapp.Job_Accepted__c;
        Boolean AppTrue = thisApplication.Job_Accepted__c;
        
       List <Candidate__c> newCandidates = [Select id, name FROM Candidate__C WHERE id =: thisApplication.Candidate__c]; 
        
        if(!AppFalse && AppTrue)
        {            
            if(newCandidates.size() > 0){
                Account converted = new Account();
            
            
                converted.RecordTypeid = accountRecordTypes.get('Person Account');
                converted.LastName = newCandidates.get(0).Name;
                converted.Phone = newCandidates.get(0).Phone__c;
              
                
                accounts.add(converted);
                
            }
            

        }

    }

    insert accounts;
}
Can we use Select query with where condition inside Apex:Page instead of using Apex:Class.
I would like to fetch data from Opportunity for the selected columns using where condition.
I am struggling to figure out how to achieve a particular query using Wave and SAQL. I know how I would do it in Apex/SOQL but can't quite figure out the correct steps/syntax to get it to work in SAQL. Any help would be greatly appreciated. Here is a description of what I need to do. I need to find all the records of a custom object Revenue Schedule that have a Schedule Date in Last Quarter or This Quarter. The Revenue Schedule object has a lookup to an Opportunity and through that, you can get to the Account. Then I need to put these schedules into buckets based on Account association.
For each Account that has Schedules in LAST and THIS Quarter, add its Revenue to Revenue Bucket #1 and increase count of Active Accounts by 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) 
For each Account that has a Schedule in LAST Quarter but not THIS Quarter, add its Revenue to Revenue Bucket #2 and increase count of Inactive Accounts by 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) 
For each Account that has a Schedule in LAST Quarter and THIS Quarter, add its Revenue to Revenue Bucket #3 and increase count of Existing Accounts to 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) .
So I have tried to run multiple queries but still cant wrap my head around the conditional logic for only updating the Count if it is the first Account of that type. I have  tried using cogroup and group by AccountId but that gives me a single row in the Result Set for each Account. I can group them by Quarter which gets me 1 row for each Quarter but how to compare the values in those two result sets? 
Is it possible to do a nested foreach? 
I am struggling to figure out how to achieve a particular query using Wave and SAQL. I know how I would do it in Apex/SOQL but can't quite figure out the correct steps/syntax to get it to work in SAQL. Any help would be greatly appreciated. Here is a description of what I need to do. I need to find all the records of a custom object Revenue Schedule that have a Schedule Date in Last Quarter or This Quarter. The Revenue Schedule object has a lookup to an Opportunity and through that, you can get to the Account. Then I need to put these schedules into buckets based on Account association.
For each Account that has Schedules in LAST and THIS Quarter, add its Revenue to Revenue Bucket #1 and increase count of Active Accounts by 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) 
For each Account that has a Schedule in LAST Quarter but not THIS Quarter, add its Revenue to Revenue Bucket #2 and increase count of Inactive Accounts by 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) 
For each Account that has a Schedule in LAST Quarter and THIS Quarter, add its Revenue to Revenue Bucket #3 and increase count of Existing Accounts to 1 (unless this is the 2nd Schedule for this Account in which case only add Revenue, do not update count) .
So I have tried to run multiple queries but still cant wrap my head around the conditional logic for only updating the Count if it is the first Account of that type. I have  tried using cogroup and group by AccountId but that gives me a single row in the Result Set for each Account. I can group them by Quarter which gets me 1 row for each Quarter but how to compare the values in those two result sets? 
Is it possible to do a nested foreach? 
Hi everybody,

I have the following scenario:

an applicant can have one or more applications, for this I am using a Person Account object and a custom object called Admisión. The object Admisión has a lookup field called Name of the Account, pointing to the Person Account or applicant, so the applicant has a related list called Admisiones.

The Admisión object has the field Stage with values Review pending, In review, Admission accepted, Admission denied. I wanted to have a Status field in the Person Account object with values "Initial contact", "Admission Inquiry", "Admission denied" and "Admission accepted", so their values change according to the stage value in the object Admisión.

The problem is: an applicant can not have a general status for all applications submitted by the applicant, as an application can have one status and the another application another status.

We would like further to build reports based on the status of the applicant, would be a good approach to add the applicant status field in the object Admisión? or wouldn't you consider even to use this field?.

I guess this can only be implemented with code.
Thinking about this: for example, if the applicant has three applications, one in stage "In review", another in stage "Denied" and the another one in stage "Accepted", the application with the "highest" level of stage should "win" and be the criterium in order to change the status of the applicant from "Admission inquiry" to "Admission accepted".

I think, this can not be done with Process Builder but programm code is needed. Does anybody know how to build a programm which makes this idea possible to implement?.

Hello everyone,

I need help on writing a trigger. The requirement is to update a field named 'Account Status' on Account on basis of 3 of its child objects activites.

The 3 child objects of Account and its relationship with account :

Finance (custom obj) : look up relationship
Opportunities : Master-Detail relationship
Calls (Custom obj) : look up relationship

So, the requirement is to first check if Account has any Finance records associated with it. If Yes, then check if there are any opportunities linked to it. If the account has any opportunities linked to it, then check if any of its oppportunities were not modified in the last one year. 

If there any opportunities not modified in last one year, then check if the account has any call record created in last one year again.

If the above criteria meets, then the account status field on account should read "disengaged" else should read "engaged".

Can someone help me on this?

Many Thanks,
Tejasvi
 

Hi Everyone,

I am having a biot of trouble creating a test class for my controller. What I have is only testing 18% of the code.

Please can someone take a look and see where I am going wrong?

Controller:
public class TrainingConfirmationSend {
    ApexPages.StandardController controller;   
 
 public course_sale__c q
 {get;set;}
    
 String op = ApexPages.currentPage().getParameters().get('id');
 
 public Id oppr   
 {get;set;}  

Public course_sale__c cf; 
 
 public TrainingConfirmationSend(ApexPages.StandardController ctrl)   
 {oppr = ctrl.getRecord().Id;}
     
 public void GetCustomFields() {
            cf = [SELECT id, Email_to_send_confirmation_to__c, courses__r.venue_address__c, courses__r.Course_Name__c, courses__r.Duration__c, courses__r.Course_Start_Date__c, courses__r.Start_Time__c, courses__r.Finish_Time__c, courses__r.Training_Tutor__r.Name FROM Course_Sale__c WHERE id = :oppr];
  }
 public PageReference emailAtt()
 {    
	EmailTemplate template = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Id = '00XD0000001dOXr'];
       
    GetCustomFields();
     
    String subject = template.Subject;
	subject = subject.replace('{!Courses__c.Course_Name__c}', cf.courses__r.Course_Name__c);
    
    String htmlBody = template.HtmlValue;
	htmlBody = htmlBody.replace('{!Courses__c.Course_Name__c}', cf.courses__r.Course_Name__c);
    htmlBody = htmlBody.replace('{!Courses__c.Duration__c}', cf.courses__r.Duration__c.format());
    htmlBody = htmlBody.replace('{!Courses__c.Course_Start_Date__c}', cf.courses__r.Course_Start_Date__c.format());
    htmlBody = htmlBody.replace('{!Courses__c.Start_Time__c}', cf.courses__r.Start_Time__c);
    htmlBody = htmlBody.replace('{!User.FirstName}', UserInfo.getFirstName());
    htmlBody = htmlBody.replace('{!Courses__c.Finish_Time__c}', cf.courses__r.finish_time__c);
    htmlBody = htmlBody.replace('{!Courses__c.Venue_Address__c}', cf.courses__r.venue_address__c);
    htmlBody = htmlBody.replace('{!Courses__c.Training_Tutor__c}', cf.courses__r.Training_Tutor__r.Name);
    
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
     List<String> toaddress = new List<String>();
     toaddress.add(string.valueof(cf.Email_to_send_confirmation_to__c));
        mail.settoaddresses(toaddress);
        mail.setReplyTo('trainingbookings@certsure.com');
        mail.setSenderDisplayName('Certsure Training');
        mail.setBccSender(false);
        mail.setUseSignature(false);
        mail.saveAsActivity = true;
        mail.setSubject(subject);
        mail.setHtmlBody(htmlBody);
        
      //Set email file attachments
        List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
        for (Attachment a : [select Id, Name, Body, BodyLength from Attachment where ParentId = :oppr])
        {
     
     // Add to attachment file list
        Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
        efa.setFileName(a.Name);
        efa.setBody(a.Body);
        fileAttachments.add(efa);
        } 
     
     // for the T&C's
        Document doc = [select id, name, body, contenttype, developername, type from Document where id = '015D0000003rgYq'][0];
        Messaging.Emailfileattachment MyDocefa = new Messaging.Emailfileattachment();
        MyDocefa.setContentType(doc.contentType);
        MyDocefa.setFileName(doc.developerName+'.'+doc.type);
        MyDocefa.setBody(doc.Body);
        fileAttachments.add(MyDocefa);  
        mail.setFileAttachments(fileAttachments);

      //Send email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
  
     //Log Completed Activity
        GetCustomFields();
        String userId = UserInfo.getUserId();
     	Task t=new Task();
     	t.Subject = 'Confirmation Sent';
     	t.Status = 'Completed';
        t.Type = 'Email';
     	t.ActivityDate = System.Today();
     	t.WhatId = cf.id;
     	t.Description = 'Confirmation Successfully Sent to '+cf.Email_to_send_confirmation_to__c;
        t.OwnerId = userid;
        t.Priority = 'Normal';
        insert t;       
        return null;
}
    
}

test class:
@istest
public class testTrainingConfirmationSend
{
  static testmethod void TrainingConfirmationSend()
  {
        Account acc=new Account();
        acc.Name = 'Test';
        insert acc;
        
        Courses__c crs=new Courses__c();
        crs.Name = 'Test';
        insert crs;
               
        Opportunity op=new Opportunity();
        op.RecordTypeId = '012D0000000kBZn';
        op.Name = 'Test';
        op.AccountId = acc.Id;
        op.Opportunity_Type_NICEIC_Training__c = 'In House Course';
        op.Customer_Type__c = 'New';
        op.StageName = 'Open';
        Date dt = Date.Today();
        op.CloseDate = dt;
        insert op;        
         
        Course_Sale__c cs=new Course_Sale__c();
        Decimal delnum = 4;
        cs.Delegates__c = delnum;
        cs.Opportunity__c = op.Id;
        cs.Email_to_send_confirmation_to__c = 'joehayes89@gmail.com';
        cs.Total_Revenue__c = delnum;
        cs.Courses__c = crs.Id;
        insert cs;        
        
        Attachment attach=new Attachment();    
        attach.Name='Test Attachment';
        Blob bodyBlob=Blob.valueOf('A Little Test From Joe');
        attach.body=bodyBlob;
        attach.parentId=cs.id;
        insert attach;
      
        Task t=new Task();
     	t.Subject = 'Confirmation Sent';
     	t.Status = 'Completed';
        t.Type = 'Email';
     	t.ActivityDate = System.Today();
     	t.WhatId = cs.id;
     	t.Description = 'Confirmation Successfully Sent to '+cs.Email_to_send_confirmation_to__c;
        String userId = UserInfo.getUserId();
        t.OwnerId = userid;
        t.Priority = 'Normal';
        insert t;
        
        List<Attachment> attachments=[select id, name from Attachment where parent.id=:cs.id];
        System.assertEquals(1, attachments.size());
        Task[] task = [select id, subject from task where whatId =:cs.Id];
        System.assertEquals('Confirmation Sent', task[0].subject);

      PageReference pageRef = Page.SendTrainingConfirmation;
      Test.setCurrentPage(pageRef);
      TrainingConfirmationSend con = new TrainingConfirmationSend(new ApexPages.StandardController(cs));	
      String nextPage = con.emailAtt().geturl();
      
  }
}

Thanks for your help. I can't work it out at all.


Thanks
Joe
Hello ,

I have the below JScript as a button.. Everytime I am clicking it, the page refreshes but nothing changes..
Can some one point out what am is missing in there..
I am building a WF on this.. so field update is necessary... 

Button is supposed to change the RT value from Claim to Risk and manipulate data in successive fields...
 
{!REQUIRESCRIPT("/soap/ajax/***/connection.js")}
var a = false;
if({!Case.Possible_Risk__c} != true)
a = confirm('Are you sure you want to change this from a Claim to a Risk?');
var recordType = sforce.connection.query('select id, name from recordtype where sobjecttype=\'Case\' and name = \'US Risk\'');
var recordTypeEMEA = sforce.connection.query('select id, name from recordtype where sobjecttype=\'Case\' and name = \'EMEA Risk\'');

var records = recordType.getArray("records");
/* alert('Check records' + records); */
var recordsE = recordTypeEMEA.getArray("records");
/* alert('Check recordsE' + recordsE); */

if(a)
{
var newRecords = [];

var c = new sforce.SObject("Case");
c.id = "{!Case.Id}";
c.Possible_Risk__c = true;  // Checkbox on which my WF will depend on//
c.Reason__c = 'Risk';
c.OwnerId = '{!$User.Id}';

/* alert('Inside IF, check for EMEA' + {!ISPICKVAL(Case.Region__c, 'EMEA')}); */

if ({!ISPICKVAL(Case.Region__c, 'EMEA')})
c.RecordTypeId = recordsE[0].Id;
else
c.RecordTypeId = records[0].Id;
newRecords.push(c);

result = sforce.connection.update(newRecords);
window.location.reload();
}


Any help is appreciated.
Thanks!
 
We are trying to link documents in Sharepoint to a Documents object in Salesforce. We cannot get the Salesforce ID of the Salesforce object to prepopulate in Sharepoint, when we try to complete the process. Any ideas?
Account having a checkbox field if that flag value is true then clicking on newopportunity button it should throw error?
Hi,

I have this trigger which is fired when a campaign member is added, modified or deleted from a campaign to help with auditing purposes. What i am trying to do is to get it to populate either the Contact or Lead field (depending on member type) with the member who has been added, modified or deleted. Currently it only gives the campaign member id but this is useless if the person has been removed from a campaign as the campaign member id will no longer exist. Any help will be greatly appreciated
 
Trigger HistoryTrack on CampaignMember (after insert, before update, before delete)
 { List<CampaignHistory__c> ch= new List<CampaignHistory__c>(); List<CampaignMember> cmOld= Trigger.old;  List<String> changes  = new List<String>(); List<String> CampHisId  = new List<String>(); integer i=0; if(Trigger.isDelete){
            for(CampaignMember cm: Trigger.old ){     
                       String s;                            
                       s='Campaign Member id ' + cm.id +
                       '  has been deleted from campaign id:  '+ cm.campaignId + '   by user  '+ userinfo.getUserName();                                        
                       changes.add(s);
                       
                       CampHisId.add(cm.campaignId);
                       CampaignHistory__c c= new CampaignHistory__c();               
                       c.Name='History'+ DateTime.now();  
                       System.debug('CName:'+ c.Name);
                       c.User__c = userinfo.getuserId() ;
                       c.CampaignId__c = CampHisId[i];
                       System.debug('CampaignId:'+c.CampaignId__c);                              
                       c.HistoryDetails__c=changes[i];
                      System.debug('CHistory:'+c.HistoryDetails__c);         
                      ch.add(c);                              
                      i++;           
             } 
        }else {      
                     for(CampaignMember cm: Trigger.new ){  
                            String s;
                            if((Trigger.isUpdate)){
                                   if(cmOld[i].status!=cm.status){    
                                          s='on dated ' + DateTime.now() +                        
                                            ' status changed from ' + cmOld[i].status + ' to ' + cm.status +                        
                                            ' by user ' + userinfo.getUserName();
                                                                                       changes.add(s);
                                          CampHisId.add(cm.campaignId);                                                  
                                          CampaignHistory__c c= new CampaignHistory__c();                          
                                          c.Name='History'+DateTime.now();
                                          System.debug('CName:'+c.Name);
                                          c.CampaignId__c=CampHisId[i];                        
                                          System.debug('CampaignId:'+c.CampaignId__c);                                      
                                          c.HistoryDetails__c=changes[i];
                                          System.debug('CHistory:'+c.HistoryDetails__c);
                                          ch.add(c); 
                                      }else if(cmOld[i].campaignId!=cm.campaignId){                        
                                                s='Changed Campaign id from : '+ cmOld[i].campaignId + 'to :' + cm.campaignId +                        
                                                    ' by user '+ userinfo.getUserName();  
                                              changes.add(s);                        
                                          CampHisId.add(cm.campaignId);                                                            
                                          CampaignHistory__c c= new CampaignHistory__c();                           
                                          c.Name='History'+DateTime.now();
                                          System.debug('CName:'+c.Name);              
                                          c.CampaignId__c=CampHisId[i];                   
                                          System.debug('CampaignId:'+c.CampaignId__c);                                          
                                          c.HistoryDetails__c=changes[i];
                                          System.debug('CHistory:'+c.HistoryDetails__c);                         
                                          ch.add(c);
                                         }             
                           }else if(Trigger.isInsert){                                
                                       s='A new Campaign Member id : ' + cm.id + ' has been added to Campaign id :' + cm.campaignId +                                                          ' by user '+ userinfo.getUserName();
                                       changes.add(s);                    
                                       CampHisId.add(cm.campaignId);                    
                                       System.debug('s>>>'+s);                                                                    
                                       CampaignHistory__c c= new CampaignHistory__c();
                                       c.Name='History'+DateTime.now();                   
                                       System.debug('CName:'+c.Name);
                                       c.CampaignId__c=CampHisId[i];
                                       System.debug('CampaignId:'+c.CampaignId__c);                                          
                                       c.HistoryDetails__c=changes[i];
                                       System.debug('CHistory:'+c.HistoryDetails__c);                                        
                                       ch.add(c);
                            } 
                            i++;     
                       }         
                }    
                insert ch;
     }




Tom
Hi, 
In the object Contacts, there is "age" field which is a formula field depending on the birthdate. 
In another object- Events, I want to know the age of the contact in each event. for example, if she was 17 years old, and the event was in 1/1/2015, I still want to see the same age (17 Y/O) even if now it's 1/1/18 for instance. 
How can I keep the age so it won't automatically change?

Thanks a lot!
 
I need to write a trigger to nofity new members when they are added to an account team.  My code doesn't seem to work, any help or ideas?

trigger Notify_Account_Team on Account (before insert, before update) {
    for(Account acct : trigger.new){
        List<Messaging.SingleEmailMessage> atm = new List<Messaging.SingleEmailMessage>(); 
        EmailTemplate et=[Select id from EmailTemplate where
                          DeveloperName=:'Notify_Assign'];
            List<AccountTeamMember> recips = new List<AccountTeamMember>(
[SELECT UserId
FROM AccountTeamMember
for(AccountTeamMember rid : recips){
mail.setTargetObjectId(rid.UserId);
mail.setSenderDisplayName('Salesforce System');
mail.setUseSignature(false);
mail.setBccSender(false);
mail.setSaveAsActivity(false);
mail.setTemplateId(et.Id);
        }

    }
atm.add(mail);

}
I am trying to find a way to send emails from Salesforce1 and I think the only way might be to make a VF page of the Send Email page.  I need to be able to use email templates and preview it.

I have a VF page in a custom object consisting of 2 Text Area Field viz. 'Choose' and 'Weights'

In 'Choose' Text Area, I enter options:
a
b
c
d


And in 'Weights' Text Area, I enter options:

1
2
3
4

I want to relate one weight to one option. Say a-1, b-2, c-3, d-4

The code to seperate each field be:
 

private List<SelectOption> stringToSelectOptions(String str){
    List<String> strList = str.split('\\r|\n');
    List<SelectOption> returnVal = new List<SelectOption>();
    for(String s: strList){
      returnVal.add(new SelectOption(s,s));
    }
    return returnVal;
But now I am unable to link it to the previous 'Choose' field and display in the record.
Hello friends
request your help in writing the trigger code. LastName in contact should be unqiue.

apex class code:
=============
public class Prevent
{
   public void Display(Id[] currentrecordId)
   {
          list<Contact> con=[select LastName from Contact where Id=:currentrecordId];
         for(Contact c:con)
          {
                if (con.size()>0)
                   c.LastName.AddError('LastName Already Exists');
          }
      }
}

Trigger Code:
==========
trigger trg_LastName on Contact (before insert,before update)
{
    if (trigger.isBefore)
    {
          if (trigger.isInsert || trigger.isUpdate)
          {
          
                Prevent obj=new Prevent();
          
                 for(Id consid:trigger.NewMap.KeySet())
                 {
                    obj.Display(consid);
                 }
          }
    }
}

When I save the trigger , I get error message as :Error: Compile Error: Method does not exist or incorrect signature: [Prevent].Display(Id) at line 12 column 21

Please let me know how to resolve this or any issue with the apex class code itself..

Regards
Krishna Casukhela
I have this trigger that i created but i am unable to figure out how to get the query out of the for loop, my trigger will run but i know it will hit some governer limits. 

trigger AcceptJobAndCreateEmployee on Candidate_Application__c (after update) {
    
    //This will be the list to add the new candidate
    List<Account> accounts = new List<Account>();

    //Query for the Account Record Types
    List<RecordType> rtypes = [Select name, id FROM RecordType WHERE sObjectType = 'Account' AND IsPersonType = True];
   
    Map<String,String> accountRecordTypes = new Map<String,String>();
        for(RecordType rt: rtypes){
            accountRecordTypes.put(rt.Name,rt.id);
        }
        
    

    for(Candidate_Application__c thisApplication: Trigger.new)
    {
        Candidate_Application__c oldApp = Trigger.oldMap.get(thisApplication.id);
        Boolean AppFalse = oldapp.Job_Accepted__c;
        Boolean AppTrue = thisApplication.Job_Accepted__c;
        
       List <Candidate__c> newCandidates = [Select id, name FROM Candidate__C WHERE id =: thisApplication.Candidate__c]; 
        
        if(!AppFalse && AppTrue)
        {            
            if(newCandidates.size() > 0){
                Account converted = new Account();
            
            
                converted.RecordTypeid = accountRecordTypes.get('Person Account');
                converted.LastName = newCandidates.get(0).Name;
                converted.Phone = newCandidates.get(0).Phone__c;
              
                
                accounts.add(converted);
                
            }
            

        }

    }

    insert accounts;
}