• Chad Reynolds
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Created a formula field on my account object to assign an account score based on the first 3 digits of the NAICS code. Cannot get it under 5,000 characters! Currently sitting at 7,300. Formula works as expected when I split it up into two fields, however the business wants to see the calc in one field. I know the worst case scenario is creating a workflow rule to update a static field and then reference that in the formula, but wanted to see if anyone can point out where I can save some characters in this bad boy! Thank you for helping in advance.

IF(BEGINS( NaicsCode , "221")  ||  BEGINS( NaicsCode , "333")||  BEGINS( NaicsCode , "519")||  BEGINS( NaicsCode , "523")||  BEGINS( NaicsCode , "531"),95,
IF(BEGINS( NaicsCode , "525"),85,
IF(BEGINS( NaicsCode , "211")||  BEGINS( NaicsCode , "237")||  BEGINS( NaicsCode , "326")||  BEGINS( NaicsCode , "517")||  BEGINS( NaicsCode , "533")||  BEGINS( NaicsCode , "999"),80,
IF(BEGINS( NaicsCode , "236")||  BEGINS( NaicsCode , "321")||  BEGINS( NaicsCode , "322")||  BEGINS( NaicsCode , "325")||  BEGINS( NaicsCode , "332")||  BEGINS( NaicsCode , "424")||  BEGINS( NaicsCode , "518")||  BEGINS( NaicsCode , "524"),75,
IF(BEGINS( NaicsCode , "113"),72,
IF(BEGINS( NaicsCode , "454")||  BEGINS( NaicsCode , "511")||  BEGINS( NaicsCode , "522")||  BEGINS( NaicsCode , "562"),70,
IF(BEGINS( NaicsCode , "327")||  BEGINS( NaicsCode , "334")||  BEGINS( NaicsCode , "481")||  BEGINS( NaicsCode , "492"),65,
IF(BEGINS( NaicsCode , "487"),62,
IF(BEGINS( NaicsCode , "238")||  BEGINS( NaicsCode , "337")||  BEGINS( NaicsCode , "446")||  BEGINS( NaicsCode , "541")||  BEGINS( NaicsCode , "561"),60,
IF(BEGINS( NaicsCode , "444")||  BEGINS( NaicsCode , "493")||  BEGINS( NaicsCode , "711")||  BEGINS( NaicsCode , "924"),55,
IF(BEGINS( NaicsCode , "311"),52,
IF(BEGINS( NaicsCode , "313")||  BEGINS( NaicsCode , "323")||  BEGINS( NaicsCode , "324")||  BEGINS( NaicsCode , "622"),50,
IF(BEGINS( NaicsCode , "486"),47,
IF(BEGINS( NaicsCode , "339")  ||  BEGINS( NaicsCode , "423")||  BEGINS( NaicsCode , "442")||  BEGINS( NaicsCode , "488")||  BEGINS( NaicsCode , "515")||  BEGINS( NaicsCode , "551")||  BEGINS( NaicsCode , "721")||  BEGINS( NaicsCode , "811")||  BEGINS( NaicsCode , "812")||  BEGINS( NaicsCode , "921"),45,
IF(BEGINS( NaicsCode , "312")  ||  BEGINS( NaicsCode , "443")||  BEGINS( NaicsCode , "448")||  BEGINS( NaicsCode , "451")||  BEGINS( NaicsCode , "452")||  BEGINS( NaicsCode , "512")||  BEGINS( NaicsCode , "621")||  BEGINS( NaicsCode , "624")||  BEGINS( NaicsCode , "813")||  BEGINS( NaicsCode , "925"),40,
IF(BEGINS( NaicsCode , "482"),37,
IF(BEGINS( NaicsCode , "212")||  BEGINS( NaicsCode , "213")||  BEGINS( NaicsCode , "315")||  BEGINS( NaicsCode , "336"),35,
IF(BEGINS( NaicsCode , "453")||  BEGINS( NaicsCode , "532")||  BEGINS( NaicsCode , "926"),30,
IF(BEGINS( NaicsCode , "111")  ||  BEGINS( NaicsCode , "112")||  BEGINS( NaicsCode , "115")||  BEGINS( NaicsCode , "335")||  BEGINS( NaicsCode , "484")||  BEGINS( NaicsCode , "485")||  BEGINS( NaicsCode , "611")||  BEGINS( NaicsCode , "713")||  BEGINS( NaicsCode , "922"),25,
IF(BEGINS( NaicsCode , "483"),22,
IF(BEGINS( NaicsCode , "331")||  BEGINS( NaicsCode , "491")||  BEGINS( NaicsCode , "623")||  BEGINS( NaicsCode , "722"),20,
IF(BEGINS( NaicsCode , "928"),17,
IF(BEGINS( NaicsCode , "114")||  BEGINS( NaicsCode , "441")||  BEGINS( NaicsCode , "445")||  BEGINS( NaicsCode , "447")||  BEGINS( NaicsCode , "712")||  BEGINS( NaicsCode , "923"),15,
IF(BEGINS( NaicsCode , "316"),12,
IF(BEGINS( NaicsCode , "314"),10,
NULL)))))))))))))))))))))))))
Good Afternoon!

I have a formula field on the account object that is referencing the NAICS Code to apply a "score" value. I expect the formula to throw the value 42 when the NAICS field is blank, however it is throwing a 95. Any ideas as to what I could be doing wrong based on the formula below? Any help is greatly appreciated!

VALUE(IF(AND(Account_Age_days__c < 180, Account_Age_days__c  >=  1),

IF(CONTAINS("221:333:519:523:531",LEFT(NaicsCode,3)),"95", 
IF(CONTAINS("525",LEFT(NaicsCode,3)),"85", 
IF(CONTAINS("211:237:326:517:533:999",LEFT(NaicsCode,3)),"80", 
IF(CONTAINS("236:321:322:325:332:424:518:524",LEFT(NaicsCode,3)),"75", 
IF(CONTAINS("113",LEFT(NaicsCode,3)),"72", 
IF(CONTAINS("454:511:522:562",LEFT(NaicsCode,3)),"70", 
IF(CONTAINS("327:334:481:492",LEFT(NaicsCode,3)),"65", 
IF(CONTAINS("487",LEFT(NaicsCode,3)),"62", 
IF(CONTAINS("238:337:446:541:561",LEFT(NaicsCode,3)),"60", 
IF(CONTAINS("444:493:711:924",LEFT(NaicsCode,3)),"55", 
IF(CONTAINS("311",LEFT(NaicsCode,3)),"52", 
IF(CONTAINS("313:323:324:622",LEFT(NaicsCode,3)),"50", 
IF(CONTAINS("486",LEFT(NaicsCode,3)),"47", 
IF(CONTAINS("339:423:442:488:515:551:721:811:812:921",LEFT(NaicsCode,3)),"45", 
IF(CONTAINS("312:443:448:451:452:512:621:624:813:925",LEFT(NaicsCode,3)),"40", 
IF(CONTAINS("482",LEFT(NaicsCode,3)),"37", 
IF(CONTAINS("212:213:315:336",LEFT(NaicsCode,3)),"35", 
IF(CONTAINS("453:532:926",LEFT(NaicsCode,3)),"30", 
IF(CONTAINS("111:112:115:335:484:485:611:713:922",LEFT(NaicsCode,3)),"25", 
IF(CONTAINS("483",LEFT(NaicsCode,3)),"22", 
IF(CONTAINS("331:491:623:722",LEFT(NaicsCode,3)),"20", 
IF(CONTAINS("928",LEFT(NaicsCode,3)),"17", 
IF(CONTAINS("114:441:445:447:712:923",LEFT(NaicsCode,3)),"15", 
IF(CONTAINS("316",LEFT(NaicsCode,3)),"12", 
IF(CONTAINS("314",LEFT(NaicsCode,3)),"10",
"42"
))))))))))))))))))))))))),

""
))
Good Morning, 

Below is a trigger I wrote to sum the number of activities on a given opportunity. I am getting an error at line 20, unexpected token: 'Map'.

Any ideas on what I could be doing wrong? This is the first trigger I have written so go easy on me :)

trigger CountTasks on Opportunity (before update) {
     
    // Put all Opportunities into a Set
    Set<string> allOppIDs = new Set<string>();
    for (Opportunity newOpp : Trigger.new) {
        allOppIDs.add(newOpp.ID);
        System.debug('ID added: ' + newOpp.ID);
    }
     
    //Query All Tasks to find Tasks with matching IDs
    List<task> allTasks = [SELECT Id, Status, WhatID from Task
                           WHERE WhatID IN :allOppIDs];
    System.debug('allTasks is ' + allTasks.size());
    // Create a Map that lets you search for Tasks by their ID - faster than SOQL each time
     
    List<string> TaskArray = new List<string>(); //All Tasks
    List<string> IDToTaskMapOpen = new List<string>(); //usedforOpenTasks
    List<string> IDToTaskMapClosed = new List<string>(); //usedforClosedTasks
     
    Map<string nteger=""> elCountAll = new Map<string nteger="">(); //Count of All Tasks
    Map<string nteger=""> elCountOpen = new Map<string nteger="">(); //Count of Open Tasks
    Map<string nteger=""> elCountClosed = new Map<string nteger="">(); //Count of Closed Tasks
     
     
     
    for (Task u : allTasks) {
        if (u.Status != 'Completed' ) {
            IDToTaskMapOpen.add(u.WhatID);
            System.debug('Added Open Task');
             
        }
        if (u.Status == 'Completed') {
            System.debug('Added Completed Task');
            IDToTaskMapClosed.add(u.WhatID);
             
        }
        TaskArray.add(u.WhatID);
    } 
     
    System.debug(allTasks.size());
    System.debug(IDToTaskMapOpen.size());
    System.debug(IDToTaskMapClosed.size());
     
     
     
    // Get the matching tasks from the Map - and count Status
    //Start with our Opportunity
    for (Opportunity newOpp : Trigger.new) {
         
        //Count all Tasks
        for(String key : TaskArray)
        {
            if(!elCountAll.containsKey(key)){
                elCountAll.put(key,0);
            }
            Integer currentInt=elCountAll.get(key)+1;
            elCountAll.put(key,currentInt);
        }
         
         
        //Count all Open Tasks
        for(String key1 : IDToTaskMapOpen)
        {
            if(!elCountOpen.containsKey(key1)){
                elCountOpen.put(key1,0);
            }
            Integer currentInt1=elCountOpen.get(key1)+1;
            elCountOpen.put(key1,currentInt1);
        }
         
        //Count all Closed Tasks
        for(String key2 : IDToTaskMapClosed)
        {
            if(!elCountClosed.containsKey(key2)){
                elCountClosed.put(key2,0);
            }
            Integer currentInt2=elCountClosed.get(key2)+1;
            elCountClosed.put(key2,currentInt2);
        }
         
         
        //Finally update the record
        //All Activities
        newOpp.AllTasks__c = elCountAll.get(newOpp.ID);
         
        //Open & Not Started Tasks
        newOpp.Open_Tasks__c = elCountOpen.get(newOpp.ID);
         
        //Closed Tasks
        newOpp.Closed_Tasks__c = elCountClosed.get(newOpp.ID);
         
    }
     
     
}
</string></string></string></string></string></string></string></string></string></string></string></string></task></string></string>
Created a formula field on my account object to assign an account score based on the first 3 digits of the NAICS code. Cannot get it under 5,000 characters! Currently sitting at 7,300. Formula works as expected when I split it up into two fields, however the business wants to see the calc in one field. I know the worst case scenario is creating a workflow rule to update a static field and then reference that in the formula, but wanted to see if anyone can point out where I can save some characters in this bad boy! Thank you for helping in advance.

IF(BEGINS( NaicsCode , "221")  ||  BEGINS( NaicsCode , "333")||  BEGINS( NaicsCode , "519")||  BEGINS( NaicsCode , "523")||  BEGINS( NaicsCode , "531"),95,
IF(BEGINS( NaicsCode , "525"),85,
IF(BEGINS( NaicsCode , "211")||  BEGINS( NaicsCode , "237")||  BEGINS( NaicsCode , "326")||  BEGINS( NaicsCode , "517")||  BEGINS( NaicsCode , "533")||  BEGINS( NaicsCode , "999"),80,
IF(BEGINS( NaicsCode , "236")||  BEGINS( NaicsCode , "321")||  BEGINS( NaicsCode , "322")||  BEGINS( NaicsCode , "325")||  BEGINS( NaicsCode , "332")||  BEGINS( NaicsCode , "424")||  BEGINS( NaicsCode , "518")||  BEGINS( NaicsCode , "524"),75,
IF(BEGINS( NaicsCode , "113"),72,
IF(BEGINS( NaicsCode , "454")||  BEGINS( NaicsCode , "511")||  BEGINS( NaicsCode , "522")||  BEGINS( NaicsCode , "562"),70,
IF(BEGINS( NaicsCode , "327")||  BEGINS( NaicsCode , "334")||  BEGINS( NaicsCode , "481")||  BEGINS( NaicsCode , "492"),65,
IF(BEGINS( NaicsCode , "487"),62,
IF(BEGINS( NaicsCode , "238")||  BEGINS( NaicsCode , "337")||  BEGINS( NaicsCode , "446")||  BEGINS( NaicsCode , "541")||  BEGINS( NaicsCode , "561"),60,
IF(BEGINS( NaicsCode , "444")||  BEGINS( NaicsCode , "493")||  BEGINS( NaicsCode , "711")||  BEGINS( NaicsCode , "924"),55,
IF(BEGINS( NaicsCode , "311"),52,
IF(BEGINS( NaicsCode , "313")||  BEGINS( NaicsCode , "323")||  BEGINS( NaicsCode , "324")||  BEGINS( NaicsCode , "622"),50,
IF(BEGINS( NaicsCode , "486"),47,
IF(BEGINS( NaicsCode , "339")  ||  BEGINS( NaicsCode , "423")||  BEGINS( NaicsCode , "442")||  BEGINS( NaicsCode , "488")||  BEGINS( NaicsCode , "515")||  BEGINS( NaicsCode , "551")||  BEGINS( NaicsCode , "721")||  BEGINS( NaicsCode , "811")||  BEGINS( NaicsCode , "812")||  BEGINS( NaicsCode , "921"),45,
IF(BEGINS( NaicsCode , "312")  ||  BEGINS( NaicsCode , "443")||  BEGINS( NaicsCode , "448")||  BEGINS( NaicsCode , "451")||  BEGINS( NaicsCode , "452")||  BEGINS( NaicsCode , "512")||  BEGINS( NaicsCode , "621")||  BEGINS( NaicsCode , "624")||  BEGINS( NaicsCode , "813")||  BEGINS( NaicsCode , "925"),40,
IF(BEGINS( NaicsCode , "482"),37,
IF(BEGINS( NaicsCode , "212")||  BEGINS( NaicsCode , "213")||  BEGINS( NaicsCode , "315")||  BEGINS( NaicsCode , "336"),35,
IF(BEGINS( NaicsCode , "453")||  BEGINS( NaicsCode , "532")||  BEGINS( NaicsCode , "926"),30,
IF(BEGINS( NaicsCode , "111")  ||  BEGINS( NaicsCode , "112")||  BEGINS( NaicsCode , "115")||  BEGINS( NaicsCode , "335")||  BEGINS( NaicsCode , "484")||  BEGINS( NaicsCode , "485")||  BEGINS( NaicsCode , "611")||  BEGINS( NaicsCode , "713")||  BEGINS( NaicsCode , "922"),25,
IF(BEGINS( NaicsCode , "483"),22,
IF(BEGINS( NaicsCode , "331")||  BEGINS( NaicsCode , "491")||  BEGINS( NaicsCode , "623")||  BEGINS( NaicsCode , "722"),20,
IF(BEGINS( NaicsCode , "928"),17,
IF(BEGINS( NaicsCode , "114")||  BEGINS( NaicsCode , "441")||  BEGINS( NaicsCode , "445")||  BEGINS( NaicsCode , "447")||  BEGINS( NaicsCode , "712")||  BEGINS( NaicsCode , "923"),15,
IF(BEGINS( NaicsCode , "316"),12,
IF(BEGINS( NaicsCode , "314"),10,
NULL)))))))))))))))))))))))))
Good Morning, 

Below is a trigger I wrote to sum the number of activities on a given opportunity. I am getting an error at line 20, unexpected token: 'Map'.

Any ideas on what I could be doing wrong? This is the first trigger I have written so go easy on me :)

trigger CountTasks on Opportunity (before update) {
     
    // Put all Opportunities into a Set
    Set<string> allOppIDs = new Set<string>();
    for (Opportunity newOpp : Trigger.new) {
        allOppIDs.add(newOpp.ID);
        System.debug('ID added: ' + newOpp.ID);
    }
     
    //Query All Tasks to find Tasks with matching IDs
    List<task> allTasks = [SELECT Id, Status, WhatID from Task
                           WHERE WhatID IN :allOppIDs];
    System.debug('allTasks is ' + allTasks.size());
    // Create a Map that lets you search for Tasks by their ID - faster than SOQL each time
     
    List<string> TaskArray = new List<string>(); //All Tasks
    List<string> IDToTaskMapOpen = new List<string>(); //usedforOpenTasks
    List<string> IDToTaskMapClosed = new List<string>(); //usedforClosedTasks
     
    Map<string nteger=""> elCountAll = new Map<string nteger="">(); //Count of All Tasks
    Map<string nteger=""> elCountOpen = new Map<string nteger="">(); //Count of Open Tasks
    Map<string nteger=""> elCountClosed = new Map<string nteger="">(); //Count of Closed Tasks
     
     
     
    for (Task u : allTasks) {
        if (u.Status != 'Completed' ) {
            IDToTaskMapOpen.add(u.WhatID);
            System.debug('Added Open Task');
             
        }
        if (u.Status == 'Completed') {
            System.debug('Added Completed Task');
            IDToTaskMapClosed.add(u.WhatID);
             
        }
        TaskArray.add(u.WhatID);
    } 
     
    System.debug(allTasks.size());
    System.debug(IDToTaskMapOpen.size());
    System.debug(IDToTaskMapClosed.size());
     
     
     
    // Get the matching tasks from the Map - and count Status
    //Start with our Opportunity
    for (Opportunity newOpp : Trigger.new) {
         
        //Count all Tasks
        for(String key : TaskArray)
        {
            if(!elCountAll.containsKey(key)){
                elCountAll.put(key,0);
            }
            Integer currentInt=elCountAll.get(key)+1;
            elCountAll.put(key,currentInt);
        }
         
         
        //Count all Open Tasks
        for(String key1 : IDToTaskMapOpen)
        {
            if(!elCountOpen.containsKey(key1)){
                elCountOpen.put(key1,0);
            }
            Integer currentInt1=elCountOpen.get(key1)+1;
            elCountOpen.put(key1,currentInt1);
        }
         
        //Count all Closed Tasks
        for(String key2 : IDToTaskMapClosed)
        {
            if(!elCountClosed.containsKey(key2)){
                elCountClosed.put(key2,0);
            }
            Integer currentInt2=elCountClosed.get(key2)+1;
            elCountClosed.put(key2,currentInt2);
        }
         
         
        //Finally update the record
        //All Activities
        newOpp.AllTasks__c = elCountAll.get(newOpp.ID);
         
        //Open & Not Started Tasks
        newOpp.Open_Tasks__c = elCountOpen.get(newOpp.ID);
         
        //Closed Tasks
        newOpp.Closed_Tasks__c = elCountClosed.get(newOpp.ID);
         
    }
     
     
}
</string></string></string></string></string></string></string></string></string></string></string></string></task></string></string>