• Rory McDonnell
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies
Would anybody be able to shed some light on this scenario?

An account I work with is using mydomain for their new lightning instance of Salesforce.

A web visitor trying to access their home page is somehow being re-directed to login to the mydomain page in Salesforce.

The system that has identified it is called Leadfeeder but it hasn’t been connected to Salesforce. I would be able to get this info from Google Analytics.

The homepage is question is 
https://www.schoolbusinessservices.co.uk/ and the salesforce mydomain is 
http://schoolbusinessservices.my.salesforce.com/

Here is a screenshot from leadfeeder
User-added image
Appreciate this isn't a typical question but wondering if anybody would have any idea what's going on?
Hi, I am still in the early days of my apex journey so trying to get my head around basic concepts.

I have built a simple enough trigger which does the following. When somebody is creating or update a lead it looks at the values in 6 key fields and then counts the number that are not null. It then enters that value in the 'Key fields' field on the lead record.

Secondly if this value is greater than or equal to three it creates a task for each of the completed key fields.

So far I have gotten the first stage of the process to work by using before insert and before update. However now since the task record will require a lead ID I suspect I will need to use 'after update/insert' capabilities.

What would you suggest is the best way to modify my code to account for these two requirments.
 
trigger KeyFieldsPopulated on Lead (before insert, before update) {
     
    for (Lead l : Trigger.New) {
        //Create list to store key fields 
        List<String> KeyFields = new List<String>();
        KeyFields.add(l.FirstName);
        KeyFields.add(l.LastName);
        KeyFields.add(l.Email);
        KeyFields.add(l.Phone);
        KeyFields.add(l.Website);
        KeyFields.add(l.Title);
        
        
        //Create list to store key fields that have a value
        List<String> KeyFieldsPopulated = new List<String>();
        
        //Create a counter variable to track how many key fields have a value
        Integer counter = 0;
        
        //Loop through the key fields 
        for (Integer i = 0; i<KeyFields.size(); i++) {
            if (KeyFields[i]!=null) {
                KeyFieldsPopulated.add(KeyFields[i]);
                counter = counter + 1;
                
            }
            l.Key_Fields__c = counter;
        }
        
            //Loop through the populated key fields and create a task
            if (counter >= 3) {
                for (Integer j = 0; j < KeyFieldsPopulated.size(); j++) {
                    Task t = new Task();
                    t.Subject = 'Verify the '+ KeyFieldsPopulated[j] + ' field';
                    t.WhatId = l.Id;
                }
             
          }
       
    }

}

 
Hi I have created the following Trigger that creates ten opportunities when an account has more than 99 employees. It is working as expected and the opps are being created, only issue is that they are not being linked to the account record. Any idea why that is the case?
 
trigger CreateTenOpps on Account (before insert, before update) {
    
    List<Opportunity> TenOpps = New List<Opportunity>();
    
    for (Account acc : Trigger.new) {
        if (acc.NumberOfEmployees > 99) {
            for (Integer i = 0; i < 10; i++) {
                Opportunity opp = New Opportunity(CloseDate = date.today(), 
                                                  StageName = 'Prospecting', 
                                                  Name = 'Trigger Opp',
                                                  AccountId = acc.Id);
                TenOpps.add(opp);
            }
            insert TenOpps;
        }
    }

}

 
Hi I am somewhat of a novice when it comes to apex and can't seem to work out what the problem is with line 7 of my code. I am building a practice trigger that creates 10 identical opportunities whenever an account has more than 99 employees.

I think I have set up the for loop correctly but in the developer console 'Problem' there are a number of messages on line 7
- Expecting ';' but was a '<'
- Expecting ';' but was a ','
- Expecting ';' but was a ')'

Any suggestions?
trigger CreateTenOpps on Account (before insert) {
    
    List<Opportunity> TenOpps = New List<Opportunity>();
    
    for (Account acc : Trigger.new) {
        if (acc.NumberOfEmployees > 100) {
            for (Integer i = 0, i < 10, i++) {
                Opportunity opp = New Opportunity(CloseDate = date.today(), 
                                                  StageName = 'Prospecting', Name = 'Trigger Opp');
                TenOpps.add(opp);
            }
            insert TenOpps;
        }
    }

}

 
Hi I am learning how to build triggers and am trying to do the following.

When a new lead is created with a specific company name, update two fields on the lead record and also create a new task. 

My understanding is that since it is a new record I would need to use an AFTER INSERT trigger as the task will need the newly created lead ID as a reference in the WhatID. But seeing as I also need to update fields on the lead record it doesn't seem that the After Insert will allow that.

Am I stuck with choosing between a Before Insert so I can update my lead record, and an After Insert if I want to create a task.

I'm pretty sure there is a simple solution but still very new to Apex.
Hi I have created the following Trigger that creates ten opportunities when an account has more than 99 employees. It is working as expected and the opps are being created, only issue is that they are not being linked to the account record. Any idea why that is the case?
 
trigger CreateTenOpps on Account (before insert, before update) {
    
    List<Opportunity> TenOpps = New List<Opportunity>();
    
    for (Account acc : Trigger.new) {
        if (acc.NumberOfEmployees > 99) {
            for (Integer i = 0; i < 10; i++) {
                Opportunity opp = New Opportunity(CloseDate = date.today(), 
                                                  StageName = 'Prospecting', 
                                                  Name = 'Trigger Opp',
                                                  AccountId = acc.Id);
                TenOpps.add(opp);
            }
            insert TenOpps;
        }
    }

}

 
Hi I am somewhat of a novice when it comes to apex and can't seem to work out what the problem is with line 7 of my code. I am building a practice trigger that creates 10 identical opportunities whenever an account has more than 99 employees.

I think I have set up the for loop correctly but in the developer console 'Problem' there are a number of messages on line 7
- Expecting ';' but was a '<'
- Expecting ';' but was a ','
- Expecting ';' but was a ')'

Any suggestions?
trigger CreateTenOpps on Account (before insert) {
    
    List<Opportunity> TenOpps = New List<Opportunity>();
    
    for (Account acc : Trigger.new) {
        if (acc.NumberOfEmployees > 100) {
            for (Integer i = 0, i < 10, i++) {
                Opportunity opp = New Opportunity(CloseDate = date.today(), 
                                                  StageName = 'Prospecting', Name = 'Trigger Opp');
                TenOpps.add(opp);
            }
            insert TenOpps;
        }
    }

}

 
Hi I am learning how to build triggers and am trying to do the following.

When a new lead is created with a specific company name, update two fields on the lead record and also create a new task. 

My understanding is that since it is a new record I would need to use an AFTER INSERT trigger as the task will need the newly created lead ID as a reference in the WhatID. But seeing as I also need to update fields on the lead record it doesn't seem that the After Insert will allow that.

Am I stuck with choosing between a Before Insert so I can update my lead record, and an After Insert if I want to create a task.

I'm pretty sure there is a simple solution but still very new to Apex.