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

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
  • 0

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?

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)


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

    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;
      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){
        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');
        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>();
        //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()){
                mapOfLeadIdToMQL.put(mqlRec.Lead__c, mqlRec);
              MQL_Record__c prevMQL = mapOfLeadIdToMQL.get(mqlRec.Lead__c);
              if(prevMQL.MQL_Date__c < mqlRec.MQL_Date__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;
        //update records

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)){
    // 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){
    // 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;}


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?