• Jim Gentile
  • NEWBIE
  • 0 Points
  • Member since 2013
  • Consultant
  • Self Emplyed


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 0
    Replies
All,

I'm currently using Cloudingo to merge records.  I'm receiving an error that says "When merging portal enabled accounts, the master record must be portal enabled."

I have found that one of my Apex Classes includes the phrase.  In security I have removed the profile that Cloudingo uses for login.  However I still receive the error.

I cannot find a way to disable the class altogether.  Can someone guide me on this?






 
All,
Remedyforce went live today with an update to Remedyforce.
I am now receiving the following error when attempting to update account names.  Has anyone else seen this issue and how did you fix it if you did?

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger BMCServiceDesk.AccountTrigger caused an unexpected exception, contact your administrator: BMCServiceDesk.AccountTrigger: execution of BeforeUpdate caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times): (BMCServiceDesk)

 
All,

I would like to ask for help determining what the following trigger does.  I inherited an instance and trying to break down some of the code.  I just can't figure this one out (probably because I don't know Apex).  There is a description half way through the code, but I'm wondering if that description includes the entire code.

Can you help me out with a brief explanation?


public without sharing class LeadTriggerHandler {
    
    public void onAfterUpdate(Lead[] newleads){
        //update MQL records
        updateMQLRecord(newleads);
        

    }
    
    public void onBeforeInsert(Lead[] newleads){
       for(Lead l :newleads){
            if(l.LeadSource == 'Inbound Sales'){
                l.Status = 'Marketing Qualified Lead';
            }
       }
    }
    
    public void onAfterInsert(Lead[] newleads){
      
      List<MQL_Record__c> mqlRecordsToInsert = new List<MQL_Record__c>();
      //Update Inbound Sales LEads to MQL
       for(Lead l :newleads){
            if(l.LeadSource == 'Inbound Sales'){
                MQL_Record__c InboundMQL = new MQL_Record__c();
        InboundMQL.Lead__c = l.id;
        InboundMQL.MQL_Date__c = system.now();
        InboundMQL.Lead_Source_Most_Recent__c = l.LeadSource;
        InboundMQL.Lead_Source_Original__c = l.LeadSource;
        mqlRecordsToInsert.add(InboundMQL);
            }
        }
      
      System.Debug('mqlRecordsToInsert' + mqlRecordsToInsert.size());
      insert mqlRecordsToInsert;
    }
    
    
    private void updateContactRType(Lead[] newleads){
        Map<string,id> map_contactRecordTypes = new Map<string,id>();
        Set<id> convertedContactIds = new Set<id>();
        List<Contact> contactsToBeUpdated = new List<Contact>();
        for(Lead l :newleads){
            if(l.IsConverted){
                convertedContactIds.add(l.ConvertedContactId);
            }
        }
        for(RecordType iterating_RecordType : [SELECT Id, Name, DeveloperName FROM RecordType WHERE sObjectType='Contact'])
        {
            map_contactRecordTypes.put(iterating_RecordType.DeveloperName, iterating_RecordType.Id);
        }
        for(List<Contact> c_List : [SELECT id, RecordTypeId from contact where id in:convertedContactIds]){
            for(contact c :c_List){
                c.RecordTypeId = map_contactRecordTypes.get('Sales_RT');
                contactsToBeUpdated.add(c);
            }
        }
        
        if(contactsToBeUpdated != null && contactsToBeUpdated.size()>0)
            update contactsToBeUpdated ;
    }
    

    
    /*
     * Description : To update the following fields in the MQL record when a lead is updated
        - Contact Id
        - Vertical Team
        - Country
        - Lead Source Most Recent
        - Import Source Most Recent
        - Lead Source Original (if blank)
        - Import Source Original (if blank)
    */
    private void updateMQLRecord(Lead[] newleads){
      
      
      //For Inbound Sales Lead process, we need to see if an MQL exists in the past 180 days, and if not, create one.
      //Eloqua is too slow to create the MQL, and it may get lost
      List<MQL_Record__c> mqlRecordsToUpsert = new List<MQL_Record__c>();
      
      //List to Map
      Map<Id, Lead> mapOfLeads = new Map<Id, Lead>();
      mapOfLeads.putAll(newleads);
        
        //Identify the MQL records related to the leads.
        Map<Id, MQL_Record__c> mapOfMQLRecords = new Map<Id, MQL_Record__c>([Select Id, MQL_Record__c.Contact__c,MQL_Record__c.MQL_Date__c,MQL_Record__c.Converted_Date__c,MQL_Record__c.Direct_Sales_Opp__c,MQL_Record__c.Is_Converted__c,MQL_Record__c.Opportunity__c,MQL_Record__c.Lead__c,MQL_Record__c.Lead_Source_Original__c,MQL_Record__c.Import_Source_Original__c from MQL_Record__c where Lead__c in :newleads]);
        
        //create a map of Lead Id to Most Recent MQL
        Map<Id, MQL_Record__c>  mapOfLeadIdToMQL = new Map<Id, MQL_Record__c>();
        for(MQL_Record__c mqlRec : mapOfMQLRecords.values()){
            if(!mapOfLeadIdToMQL.containsKey(mqlRec.Lead__c))
                mapOfLeadIdToMQL.put(mqlRec.Lead__c, mqlRec);
            else{
              MQL_Record__c prevMQL = mapOfLeadIdToMQL.get(mqlRec.Lead__c);
              if(prevMQL.MQL_Date__c < mqlRec.MQL_Date__c){
                mapOfLeadIdToMQL.remove(mqlRec.Lead__c);
                mapOfLeadIdToMQL.put(mqlRec.Lead__c, mqlRec);
              }
            }
        }
        
        //update MQL records based on the lead values
        
        for(MQL_Record__c mqlRec : mapOfLeadIdToMQL.values()){
          Lead MQLdLead = mapOfLeads.get(mqlRec.Lead__c);
            if (MQLdLead.IsConverted && (MQLdLead.Industry != 'LM-Public Sector' || MQLdLead.Industry != 'LM-Enterprise')) {
              //Update Lead Source - Original, Lead Source - Most Recent, Import Source - Original, Import Source - Most Recent
              if (mqlRec.Lead_Source_Original__c == null || mqlRec.Lead_Source_Original__c == ''){
                mqlRec.Lead_Source_Original__c = MQLdLead.LeadSource;
              }
              if(mqlRec.Import_Source_Original__c == null || mqlRec.Import_Source_Original__c == ''){
                mqlRec.Import_Source_Original__c = MQLdLead.Import_Source__c;
              }
              mqlRec.Lead_Source_Most_Recent__c = MQLdLead.LeadSource;
              mqlRec.Import_Source_Most_Recent__c = MQLdLead.Import_Source__c;
                mqlRec.Contact__c         = MQLdLead.ConvertedContactId;
                mqlRec.Vertical_Team__c   = MQLdLead.Industry;
                mqlRec.Country__c         = MQLdLead.Country;
                mqlRecordsToUpsert.add(mqlRec);
            }
        } 
        //update records
        Database.upsert(mqlRecordsToUpsert,true);
    }
}
 
Hello,

From a previous post I was able to figure out how to write a trigger for populating the opportunity stage on a related task (https://developer.salesforce.com/forums/ForumsMain?id=906F000000091fKIAQ).

My coverage for this trigger is 0% because I do not have a test class.  Can someone help me with this code?  I should emphasize that I am brand new to triggers.

Thanks in advance for the help.

Here is what my trigger looks like:

trigger TaskRelatedToOpp on Task (before insert, before update) {

// Goal: Find the opp Stage of the opportunity that a task is related to
// and update the Opportunity_Stage__c field on the task object with the value

// If related to an Opportunity, query to find out the Opportunity number

// Create collection of tasks that are related to an opp (where the opp is listed only once)
    Set<Id> opIds = new Set<Id>();
    for(Task t : trigger.new){
        String wId = t.WhatId;
        if(wId!=null && wId.startsWith('006') && !opIds.contains(t.WhatId)){
            opIds.add(t.WhatId);
        }
    }
    // Pull in opp ids and related field to populate task record
    List<Opportunity> taskOps = [Select Id, StageName from Opportunity where Id in :opIds];
    Map<Id, Opportunity> opMap = new Map<Id, Opportunity>();
    for(Opportunity o : taskOps){
        opMap.put(o.Id,o);
    }
    // Update custom task field with custom opp field
    for(Task t : trigger.new){
        String wId = t.WhatId;
        if(wId!=null && wId.startswith('006')){
            Opportunity thisOp = opMap.get(t.WhatId);
            if(thisOp!=null){t.Opportunity_Stage__c = thisOp.StageName;}
        }
    }
}

Hello,

I would like to design specific sections of an object to expand or collapse using workflow (based on the value of picklist).  Is this possible?  If yes, will you bullet the point to follow.  If not, is there another solution?

Thanks