• Natasha Ali 3
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
Hi,
I have an existing trigger which converts leads into peron accounts if the company name is blank.
I need to also write a trigger that stops records from coming into Salesforce if that email already exisits in a contact or an account (we use person accounts).
The issue is how do I get ti working with the existing trigger (I need it to run before the trigger that converts it into a person account is run). Is there a way to combine the two or add the functionality to create the record only if the email address doesn't already exist as a contact in the org. 
Below is the autoconvert trigger:
 
Trigger AutoConvert on Lead (after insert) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted && lead.Company == null) {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.Name;
               
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(true);
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}
Any help is MUCH appreciated!!
Many Thanks,
Natasha 
 
Hi, 
I have a trigger that converts a lead into a person account if the compnany name is null (when an application comes into SF). I need to add the functionality to block an application from coming into Salesforce if the email address already exists in Salesforce. Below is the trigger:
 
Trigger AutoConvert on Lead (after insert) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted && lead.Company == null) {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.Name;
               
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(true);
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}
Any help is much appreciated :)
Many Thanks,
Natasha 
Hi,
I'm developing an API and need help with using the email address on the record as the unique identifier in both Salesforce and the third party service. Salesforce will consume the REST API but I needed to know how I can get the http callout to choose the record in the external system based on the email address. (How to match the record in SF to external system using the email address??)

ANY help is much appreciated :)
Many Thanks,
Natasha 
Hi,
I'm completely new to development and I need to develop an integration between Salesforce and a third party service (BKSB). Salesforce needs to consume the REST API. 

I need to write a trigger that will make a callout when a status changes on the custom 'Placement__c' object from '8 - Offer Accepted' to '9 - Induction Booked'. I have the following code so far (asked another dev):
trigger PlacementTrigger on Placement (before update) {
 Map<Id,Placement__c> newPlacList1=new Map<Id,Placement__c>();
 Map<Id,Placement__c> oldPlacList2=new Map<Id,Placement__c>();
 List<Placement__c> newPlacementList=new List<Placement__c>();
 newPlacList1=trigger.new;
 oldPlacList2=trigger.old;
    if(Trigger.IsUpdate && Trigger.isbefore ){
 for(Id placId : newPlacList1.keySet()){
  if(oldPlacList2.get(placId).Status__c == '8 - Offer Accepted' &&
        newPlacList1.get(placId).Status__c == '9 - Induction Booked'){
  newPlacementList.add(placList1.get(placId));
  }
 }
  PlacementTriggerHandler.handlerFunction(newPlacementList); 
    }
}
To identify the correct user's data to GET from the BKSB, the unique identifier is the email address on the Salesforce record. How do I incorporate this so the correct record is chosen in BKSB?
And where do I go from the trigger?

ANY help is much appreciated!!
Many Thanks,
Natasha 
 
Hi,
I have an existing trigger which converts leads into peron accounts if the company name is blank.
I need to also write a trigger that stops records from coming into Salesforce if that email already exisits in a contact or an account (we use person accounts).
The issue is how do I get ti working with the existing trigger (I need it to run before the trigger that converts it into a person account is run). Is there a way to combine the two or add the functionality to create the record only if the email address doesn't already exist as a contact in the org. 
Below is the autoconvert trigger:
 
Trigger AutoConvert on Lead (after insert) {
     LeadStatus convertStatus = [
          select MasterLabel
          from LeadStatus
          where IsConverted = true
          limit 1
     ];
     List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();

     for (Lead lead: Trigger.new) {
          if (!lead.isConverted && lead.Company == null) {
               Database.LeadConvert lc = new Database.LeadConvert();
               String oppName = lead.Name;
               
               lc.setLeadId(lead.Id);
               lc.setDoNotCreateOpportunity(true);
               lc.setConvertedStatus(convertStatus.MasterLabel);
               
               leadConverts.add(lc);
          }
     }

     if (!leadConverts.isEmpty()) {
          List<Database.LeadConvertResult> lcr = Database.convertLead(leadConverts);
     }
}
Any help is MUCH appreciated!!
Many Thanks,
Natasha