• SamuelDeRycke
  • SMARTIE
  • 1024 Points
  • Member since 2012
  • Technical Architect
  • PwC


  • Chatter
    Feed
  • 37
    Best Answers
  • 1
    Likes Received
  • 5
    Likes Given
  • 9
    Questions
  • 323
    Replies
Has anyone tried to use the state and country picklists on a custom address field?  
an apex test keeps failing and is keeping us from being aable to create a package.  I believe it is due to a recursive loop.  The error i a get is the following:Error:

System.LimitException: RECON:Too many SOQL queries: 101

stack trace:

Trigger.RECON.Location: line 241, column 1


The code for the class trigger that creates the error is below:


trigger Location on Location__c (before insert,after insert, before update, after update, before delete, after delete) {

    

    // Hierarchy update trigger




    if(trigger.isBefore){

        

        list<Location__c> locationsToCheck = new list<Location__c>();

        

        list<Location__c> primaryJobSites = new list<Location__c>();

        

        

        if(trigger.isUpdate || trigger.isInsert){

            

            for(Location__c l:trigger.new){

                

                if(l.Job__c !=null && l.Primary_Job_Site__c){




                    primaryJobSites.add(l);

                }else if (l.Job__c ==null && l.Primary_Job_Site__c){




                    l.Primary_Job_Site__c=false;

                }




                if(l.id!=null){

                    Location__c lOld = trigger.oldmap.get(l.id);

                

                    if((lOld.Parent_Location__c != l.Parent_Location__c) || l.Hierarchy_Level__c==null){

                        locationsToCheck.add(l);

                    }

                }else{

                    locationsToCheck.add(l);

                }

            }

            if(DeepClone.getExecuteLocationHierarchyLogic()){

                if(!locationsToCheck.isEmpty()) HierarchyHelper.checkHierarchyOnUpdate(locationsToCheck);

            }

            if(!primaryJobSites.isempty()) PrimaryJobSite.checkPrimaryJobSites (primaryJobSites); 

        }   

            

        if(trigger.isDelete){

            Set<String> locId = new Set<String>();

            for(Location__c l : trigger.old){

                locationsToCheck.add(l);

                locId.add(l.id);

            }   

            if(!locationsToCheck.isEmpty()) HierarchyHelper.getChildrenWhenDeleted(locationsToCheck);

            if(!Test.isRunningtest())

                DeepDeletion.beforeDeletionLocation(locId);

        }

    }

    

    if(trigger.isafter){

        // Hierarchy Id  and Level Assignment

        set<id> locationsToUpdate = new set<id>();

        

        if(trigger.isUpdate ){

            List<RECON__Location_Change_Log__c> lsLocChangeLog = new List<RECON__Location_Change_Log__c>();

            locationsToUpdate = new set<id>();

            for(Location__c l : trigger.new){

                Location__c lOld = trigger.oldmap.get(l.id);

                if(lOld.RECON__Complete__c  != l.RECON__Complete__c ) {

                    RECON__Location_Change_Log__c locChLog = new RECON__Location_Change_Log__c();

                    locChLog.RECON__Complete__c = l.RECON__Complete__c;

                    locChLog.RECON__complete_Old__c = lOld.RECON__Complete__c;

                    locChLog.RECON__Location__c = l.id;

                    lsLocChangeLog.add(locChLog);

                }

                if((lOld.Parent_Location__c != l.Parent_Location__c) || l.Hierarchy_Id__c == null){

                    system.debug('***adding location Id to update set: ' + l.Id);

                    locationsToUpdate.add(l.id);

                }

            }

            if(lsLocChangeLog.size() > 0) {

                insert lsLocChangeLog;

            }

            System.debug('***locationsToUpdate set: ');

            system.debug(locationsToUpdate);

            

            if(HierarchyHelper.getExecuteLocationHierarchyIdLogic()){

                HierarchyHelper.updateHierarchyIds(locationsToUpdate);

            }

            if(DeepClone.getExecuteLocationHierarchyLogic()){

                HierarchyHelper.updateHierarchyItems(HierarchyHelper.getObjNameToHierarchyCalcIds());

            }

        }

        if(trigger.isInsert){




            locationsToUpdate = new set<id>();

            for(Location__c l : trigger.new){

                locationsToUpdate.add(l.id);

            }

            if(HierarchyHelper.getExecuteLocationHierarchyIdLogic()){

                if(!Test.isRunningtest())

                    HierarchyHelper.updateHierarchyIds(locationsToUpdate);

            }

            if(DeepClone.getExecuteLocationHierarchyLogic()){

                HierarchyHelper.updateHierarchyItems(HierarchyHelper.getObjNameToHierarchyCalcIds());

            }

        }

            

        if(trigger.isDelete){

            if(HierarchyHelper.getObjNameToHierarchyCalcIds()!=null){

                HierarchyHelper.updateChildrenAfterDeletion(HierarchyHelper.getObjNameToHierarchyCalcIds());

            }

            if(!Test.isRunningtest())

                DeepDeletion.afterDeletionLocation();

        }

    }

    

    // Completion % trigger

    

    if(trigger.isBefore && CompletionHelper.getExecuteLocationCompletionLogic()){

    

        if(trigger.isUpdate){

        

            for(Location__c l : trigger.new){

                

                Location__c lOld = trigger.oldMap.get(l.id);

                

                if(l.Complete__c != lOld.Complete__c){

                    

                CompletionHelper.addLocationId(l.Parent_Location__c);

            

                }

            }       

        }

    }

        

    if(trigger.isAfter){

        if(CompletionHelper.getExecuteLocationCompletionLogic()){

            if(trigger.isUpdate || trigger.isInsert){

                if(CompletionHelper.getLocationsToUpdate() != null){

                        CompletionHelper.updateLocationTree();

                }

            }

        }

    }







    // Geocode trigger




    if(trigger.isBefore || trigger.isAfter){




        set<id> locationIds = new set<id>();




        if(trigger.isUpdate){




            for(Location__c l:trigger.new){

                

                Location__c lOld = trigger.oldmap.get(l.id);




                if (l.Street__c != lOld.Street__c || l.City__c != lOld.City__c || l.State__c != lOld.State__c || l.Zip_Code__c != lOld.Zip_Code__c){

                    locationIds.add(l.id);

                }

            }

        }

        if(trigger.isInsert && trigger.isAFter){

            for(Location__c l : trigger.new){

                locationIds.add(l.id);

            }

        }




        if(locationIds.size()>0){

            LocationGeocode.getGeocodes(locationIds);

        }

        

    } 

    

    if(trigger.isBefore) {

        List<RECON__Location__c> ls;

        if(trigger.isDelete) {

            ls = trigger.old;

        }else {

            ls =trigger.new;

        }

        List<String> jId = new List<String>();

        for(RECON__Location__c jp : ls) {

            jId.add(jp.RECON__Job__c);

        }

        if(!Test.isRunningtest())

            DeepDeletion.putJobId(jId);

    }

    if(trigger.isAfter){

        if(!Test.isRunningtest()){

            Map<String,List<RECON__Location__c>> map_Loc_JP = new Map<String,List<RECON__Location__c>>();

            Map<String, Decimal> calculateHour = new Map<String, Decimal>();

            List<RECON__Location__c> ls = [Select Id,RECON__Estimated_Man_Hour__c,RECON__Job__c From RECON__Location__c where RECON__Job__c In :DeepDeletion.getJobId()];

            for(RECON__Location__c jp : ls) {

                if(jp.RECON__Job__c != null) {

                    if(!map_Loc_JP.containsKey(jp.RECON__Job__c)){

                        map_Loc_JP.put(jp.RECON__Job__c,new List<RECON__Location__c>());

                        map_Loc_JP.get(jp.RECON__Job__c).add(jp);

                        if(jp.RECON__Estimated_Man_Hour__c == null){

                            jp.RECON__Estimated_Man_Hour__c =0;

                        }

                        calculateHour.put(jp.RECON__Job__c, jp.RECON__Estimated_Man_Hour__c);

                    } else {

                        Decimal val= jp.RECON__Estimated_Man_Hour__c;

                        if(val != null){

                        system.debug('Manish : Debug '+val+' j p :' +calculateHour+'Loc Id :'+jp.RECON__Job__c);

                            val = val+calculateHour.get(jp.RECON__Job__c);}

                        else

                            val = calculateHour.get(jp.RECON__Job__c);

                        calculateHour.put(jp.RECON__Job__c, val);

                        map_Loc_JP.get(jp.RECON__Job__c).add(jp);

                    }

                }

            }

            Map<String, RECON__Job__c> map_Loc =new Map<String, RECON__Job__c>([Select Id, RECON__Estimated_Man_Hour__c from RECON__Job__c where id In :DeepDeletion.getJobId()]);

            for(String loc : map_Loc.keySet()) {

                if(calculateHour.get(loc) != null) {

                    map_Loc.get(loc).RECON__Estimated_Man_Hour__c = calculateHour.get(loc);

                } else {

                    map_Loc.get(loc).RECON__Estimated_Man_Hour__c =0.00;

                }    

                

            }

            system.debug('@manish trigger : '+map_Loc);

            system.debug('@manish calculateHour : '+calculateHour);

            system.debug('@manish map_Loc_JP : '+map_Loc_JP);

            if(map_Loc.size() > 0)

                update map_Loc.values();

        }

    }  

    //added by sanjeev

    //set<Id> locationId = new set<Id>();   

    if(Trigger.isAfter){

        set<Id> locationId = new set<Id>();

        if(Trigger.isInsert || Trigger.isUpdate){

            for(RECON__Location__c pLoc : Trigger.new){

                locationId.add(pLoc.RECON__Parent_Location__c);

                //locationId.add(pLoc.id);

            }

        }else

        if(Trigger.isDelete){

            for(RECON__Location__c pLoc : Trigger.old){

                //locationId.add(pLoc.id);

                locationId.add(pLoc.RECON__Parent_Location__c);

            }

        }

        List<RECON__Location__c> locationList = [select RECON__Estimated_Man_Hour__c, (select RECON__Estimated_Man_Hour__c from Locations__r) from RECON__Location__c where id IN : locationId];

        if(locationList.size() > 0){

            for(RECON__Location__c loc : locationList){

                //loc.RECON__Estimated_Man_Hour__c = 0;

                List<RECON__Location__c> locChilds = loc.Locations__r;

                if(locChilds.size() > 0){

                    for(RECON__Location__c locChild : locChilds){

                        loc.RECON__Estimated_Man_Hour__c += locChild.RECON__Estimated_Man_Hour__c;

                    }

                }

            }

            update locationList;

        }

    } 

    //till here

}




Is there something simple I am missing?  Thanks for your help.
Hi,

I need help on the following requirement,


1) I am having a custom field called as "Dealer Principal__c" in my custom object called as "Account Exceptions__c"

2) There is a lookup on my custom object called as Account__c which is a lookup to the account object



1) if the account is a nornmal account (PDN Record type) , the contact(name) associated with that account with title "Dealer Principal" is populated to that field


2) If the account is a group account


the group account might have many child accounts , where it will check the contacts of all th e child accounts with the title "Dealer principal" and update the name correspondingly



so my case should work for both the scenarios

First scenario my trigger is working fine , just need help on second one


MY TRIGGER :

trigger updateaccountexceptions on AccountExceptions__c(after insert) {
    map < id, string > dealercontacts = new map < id, string > ();
    set < id > accids = new set < id > ();

    for (AccountExceptions__c acex: trigger.new) {
        accids.add(acex.account__c);
    }

    List < contact > cons = new List < contact > ([select Id, accountid, firstname, lastname from contact where title = 'Dealer Principal'
        and accountid = : accids
    ]);

    for (Contact con: cons) {
        string conname = con.firstname + ' ' + con.lastname;
        dealercontacts.put(con.accountid, conname);
    }

    list < AccountExceptions__c > acexlisttoupdate = new list < AccountExceptions__c > ();

    for (AccountExceptions__c acex: trigger.new) {
        AccountExceptions__c accex1 = new AccountExceptions__c();
        if (dealercontacts.containskey(acex.account__c)) {
            accex1.id = acex.id;
            accex1.Dealer_Principal_s__c = dealercontacts.get(acex.account__c);
            acexlisttoupdate.add(accex1);
        }
    }

    update acexlisttoupdate;

}


Thanks in Advance
Hello folks,

First of all, I'm a newbie on SalesForce, so accept my apologies if my question sounds dumb.

I have to create a trigger that creates a task after an e-mail is sent from Activity History in a custom object. I am trying to use MyCustomObject__History but I'm getting the following error: SObject type does not allow triggers: MyCustomObject__History.

Does anyone can confirm if it is possible to create a trigger for "__History" objects?

Many thanks in advance.
I have a method in command link, i am passing parameters through <apex:params> with name attribute and retriving from page parameters, which is working in my dev environment, when i try to move QA, its not calling the respective method, Very Strange...!!!!

VF Code:
<apex:commandLink action="{!showMultiSelectionPopUp}" value="{!b.name}" style="color:#2B8BD5;" rendered="{!b.recordtype='Multi Value Option Capture'}">
          <apex:param value="{!s.SchemeId}" name="selectedSchemeinMultiListControl"/>
          <apex:param value="{!b.RecordId}" name="selectedControlId"/>
          <apex:param value="{!s.SourceId}" name="selectedSourceId"/>
</apex:commandLink>

Apex Code: 
public string selectedSchemeinMultiListControl{get; set;}
public string selectedControlId{get; set;}
public string selectedSourceId {get; set;}

public pageReference showMultiSelectionPopUp(){
            selectedSchemeinMultiListControl=null;
            selectedControlId=null;
            selectedSourceId=null;
           
            selectedSchemeinMultiListControl= ApexPages.Currentpage().getParameters().get('selectedSchemeinMultiListControl');       
            selectedControlId= ApexPages.Currentpage().getParameters().get('selectedControlId');
            selectedSourceId= ApexPages.Currentpage().getParameters().get('selectedSourceId');
            return null;
}

Please help me..

Hi

The Newly created community user are not getting the WELCOME EMAIL.

i set the Deliverability='All Emails'
I checked the 'Welcome Email' checkbox also .

It is Urgent .
How i can create personal account in php ? can you please give me exact code for this. i can not findout it in PHP Toolkit 20.0
Hi All,

Can we use split  Java script functionality in salesforce.
My requirnment is if are entering Account name as Abc Itd.
then using split functionality it should take Abc limited as account name.
I have enabled the state and country picklist feature within my org. I have to refere these fields in an VF page, will the naming convention be the same as 'BillingState' & 'BillingCountry'?  What about other objects like Contacts where the field name is MailingCountry and Mailing State?

Please advise.
Hi,

We are a Research Center implementing SFDC to track our contacts, requests, events management, and newsletter needs. We have created some customized fields, but looking for a developer who can further our customization. 

Please contact Patty at pshih@uchicago.edu if interested. 

This would be paid on an hourly basis. 


Thank you,
Patty
Hi everyone,

I am helping build a product and would like users to be able to change an error message (without using the translate feature).  

Is there any way in APEX that I can check for the existence of a Custom Label?  Something like this:

<pre>
// THIS CODE WILL NOT SAVE IF THE "Label.Overwrite_Error" DOESN'T EXIST
String sError = Label.Standard_Error;
If(Label.Overwrite_Error != NULL) sError = Label.Overwrite_Error;
</pre>

Any help would be greatly appreciated!  I don't want to use Custom Settings if at all possible.

Thank you!
Hi,

I need to make a webservice calout from salesforce.the wsdl of service is importing another schema,I came to know that salesforce doesnt parse the wsdl which imports other schema's.If I remove the import section from wsdl and insert the schema directly within the wsdl,will it work?

Has anyone done this and succeeded?,Please let me know.The service WSDL is a SOA suite 11g webservice.If it works please let me know how to embed the schema withing the wsdl by removing the import statement,any example whould help.
Hi,
I have a requirement where we need to build a custom logic to sync salesforce contact,event with Microsoft Outlook.
We are NOT looking for any third party built in plugin as we have some specific requirement.
Thus, we need to connect using ms exchange web services from salesforce system.
If anyone have implemented something like this  , please provide some guidelines/steps .

Thanks in advance.
Hi folks
         Can anyone tell me  What is the purpose of view state  in salesforce?
Thanks in advance
Kartick
I have created a custom button the Case object to create a record on a custom object. The button works correctly in my full sandbox but does not work in production. And yes, I have made sure I updated the ID's I have in my code. Any help? The button does not generate an error, just does not do anything.

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

getDate = function(dateObj){
var day = dateObj.getDay() < 9 ? '0'+dateObj.getDay() : dateObj.getDay();
var month = dateObj.getMonth() < 9 ? '0'+dateObj.getMonth() : dateObj.getMonth();

return dateObj.getFullYear()+'-'+month+'-'+day;
}

var Request = new sforce.SObject('Request__c');

Request.Release_Management__c = 'a2W70000001RSwq';
Request.Related_Case__c = '{!Case.Id}';
Request.RecordTypeId ='012700000005v8J';
Request.Name = '{!Case.Subject}';
Request.Description__c = '{!Case.Description}';
Request.Case_Owner__c = '{!Case.OwnerId}';


result = sforce.connection.create([Request]);

if(result[0].success == 'true'){
    window.open("/" + result[0].id);
}
Hi Everyone,
      Can anyone tell me what is trigger.new, trigger.old and trigger.newmap ,trigger.oldmap
Trigger.oldmap.keyset with sample example


Thanks in advance
Karthick

Hello Team:
I'm debugging a portal issue trying to create a portal user from a Sites page. 
Here is the code I'm trying to execute:
try{
userId = Site.createPortalUser(u, accountId, password, true);
} catch (Exception e){
system.debug(' error in creating User Account ' + e.getMessage());
}

Here is my debug log:
14:43:20.744 (744838000)|METHOD_ENTRY|[118]|01pE0000001gvec|SiteRegisterController.__sfdc_password()
14:43:20.744 (744925000)|METHOD_EXIT|[118]|01pE0000001gvec|SiteRegisterController.__sfdc_password()
14:43:20.745 (745121000)|SYSTEM_METHOD_ENTRY|[118]|system.Site.createPortalUser(SObject, String, String, Boolean)
14:43:20.754 (754125000)|SYSTEM_METHOD_EXIT|[118]|system.Site.createPortalUser(SObject, String, String, Boolean)
14:43:20.754 ()|SYSTEM_METHOD_ENTRY|[138]|System.debug(ANY)
14:43:20.754 (754237000)|USER_DEBUG|[138]|DEBUG| userId == nul 

My try is not blowing up but the user is not getting created either. Any ideas?

 

Thank you,

There is a governor limit, that limits you to 20 concurrent API calls to the same URL endpoint. Any other concurrent calls will receive an exception. This is a hard limit and salesforce won't increase it for us (possible for other limits).

 

"A callout request to a given URL is limited to a maximum of 20 simultaneous requests."

 

I'll start with explaining why this is an issue to us, we're developing a site on force.com,  in where our customers will be able to manage their account,  manage their  sub-users and search our catalog, place&manage orders, etc. Some of that is located in salesforce, but some data, like or catalog is too big. I is stored in a seperate database, fully focussed on performing fast search on huge data quantities, at which salesforce still performs under our requirements.

 

Now, our idea was to just get the data from the other database over REST, and i've already implemented a test scenario using Remote Javascript functions, and it works great. Search functionality is a core concept of our website, and we're making  calls to the catalogue to perform autosuggest, per keystroke. This combined with calls that will be made on actual search, and other features of our website we expect to hit this governor limit very fast, as soon as having only 100 users online at the same time. We have a large international customerbase, and are thus worried and looking for a way around this governor limit.

 

Expecting the exception and making  new call in the catch (in recursive fashion) isn't something we believe is the way to go on this (are we wrong ?).  Has any of you already faced (and overcome ) this problem ? Or insights on how you would tackle this, are both grealy appreciated !

Hi fellow SF devs and admins-

 

I have worked with some other folks to get a Salesforce chat room going on IRC.  Think of it as a realtime user group.  You can access it on Freenode by joining the #salesforce channel.

 

If you're new to IRC, I personally recommend mIRC (www.mirc.com).  Various programs can be used to access IRC for any OS you may be using.  Hope to have you as a part of our community!