• Nagendra Singh 12
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
Hi All,

I'm running one time update using Execute Anonymous and getting error "Salesforce SOQL Error Too many SOQL 001" for the following code, I tried few options to change the code but couldn't run the update, anyone can help with this code please: (Opportuntiy is master for custom object Sales Team, 1 : M)

List <Opportunity> OpptySalesRep = [Select Id,Sales_Rep__c From Opportunity Where  Sales_Rep__c !=null and (CreatedDate > 2014-11-01T00:00:00Z and CreatedDate <= 2014-11-30T00:00:00Z)];    

    set<Id> opportunityIdSet = new set<Id>();
        for (Opportunity Oppty : OpptySalesRep) {
          
            list<Sales_Team__c> newGSTmember = new list<Sales_Team__c>(); 
           
            opportunityIdSet.add(Oppty.Id); //Needed for following SOQL for GST       

           //Query to get all Sales team memeber for the opportunity                    
           List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Id
                                             From Sales_Team__c
                                             Where Opportunity__c  IN: opportunityIdSet and  Producer__c = null and Opportunity__c <> null];
                                        
                                             system.debug('Number of Sales Team Member# ' + gst.size());
            
            //Reset  opportunityIdSet for avoid duplicate iteration 
             opportunityIdSet.remove(Oppty.Id);
                           
            boolean IsnewSalesRep = true;  //to check if Sales Rep already exists in GST            
              
           // Loop through the list and update GST record that matches to Sales Rep
           for (Sales_Team__c OpptyGST : gst){
              system.debug('GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);                        
              
              //Update Sales Rep to Primary
              if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
                  system.debug('INSIDE If');
                  OpptyGST.Primary__c = true;
                    IsnewSalesRep = false;
                }
              // Update Sales reps to non-primary
                else if (OpptyGST.Sales_Team_Member__c != Oppty.Sales_Rep__c && OpptyGST.Primary__c == true){
                  system.debug('INSIDE else If');
                  OpptyGST.Primary__c = false;
              }
                            
              }
            
            //Add Sales Rep to GST          
             if (IsnewSalesRep == true)
             {
             Sales_Team__c newGST = new Sales_Team__c (); //instantiate the GST object to put values
                          
            newGST.Sales_Team_Member__c = Oppty.Sales_Rep__c;
             newGST.Primary__c = true;
             newGST.Opportunity__c = Oppty.Id;
             newGSTmember.add(newGST);
             insert newGSTmember;
             
              }
           
              update gst;  
                         
           }

Hello there, Need help to get help on following, I was Parent data comparinf with child data, my query look like this:

Select ParentId, parentfield from Parent where parentfield NOT IN ( select childfield from child where parent.id = child.id)

Any advise?

 

Hi there, need help, I wrote a query that returns 3 records. and I'm reading those records in the FOR loop to update record that matchs criteria, however this record iteration no happening, anything I'm missing in following code:

my question is, I put a debug before if, I epxcet 3 entries in the log but it just one.

List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Email__c,Id
                                             From Sales_Team__c
                                             Where Sales_Team_Member__c IN: opportunityIdSet and  Producer__c = null];

for (Sales_Team__c OpptyGST : gst){
                     system.debug('Test GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);                            
                if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
                    OpptyGST.Primary__c = true;
                    OpptyGST.Email__c = 'primary@gst.com';
                   
                } 
}
 
Hello there, We have a custom field in Opportunity that is lookup to user. We have a requirement to generate a report where running user should get all the reported assign to users associated custom field that reports to him. In other words, we're not using Owner field, and want to generate report based on this custom field. Any suggestion please? 
Hi There,

We've a API user, we did password reset and then set Password Never Expires checked for this User's Profile. What I'm not sure about is since Password Never Expires setting is made after password reset,  will the password expires for this user and also how about Security Token, is there any expiry for that and if that is impacted in this case too?

Please share your thoughts

Thanks
Hi There,

We have create a VF page and it display accounts, user can select multiple account and the there is a button "Create Task", that creates the task under seach account selected. This works fine with SysAdmin profile but not for any other profile. Is there anything I can check priviledge vise. We can create taks under account by navigating to Account detail. Any suggestions please....

Thanks
Hi All,

I'm running one time update using Execute Anonymous and getting error "Salesforce SOQL Error Too many SOQL 001" for the following code, I tried few options to change the code but couldn't run the update, anyone can help with this code please: (Opportuntiy is master for custom object Sales Team, 1 : M)

List <Opportunity> OpptySalesRep = [Select Id,Sales_Rep__c From Opportunity Where  Sales_Rep__c !=null and (CreatedDate > 2014-11-01T00:00:00Z and CreatedDate <= 2014-11-30T00:00:00Z)];    

    set<Id> opportunityIdSet = new set<Id>();
        for (Opportunity Oppty : OpptySalesRep) {
          
            list<Sales_Team__c> newGSTmember = new list<Sales_Team__c>(); 
           
            opportunityIdSet.add(Oppty.Id); //Needed for following SOQL for GST       

           //Query to get all Sales team memeber for the opportunity                    
           List <Sales_Team__c> gst = [Select Sales_Team_Member__c,Primary__c,Producer__c,Opportunity__c,Id
                                             From Sales_Team__c
                                             Where Opportunity__c  IN: opportunityIdSet and  Producer__c = null and Opportunity__c <> null];
                                        
                                             system.debug('Number of Sales Team Member# ' + gst.size());
            
            //Reset  opportunityIdSet for avoid duplicate iteration 
             opportunityIdSet.remove(Oppty.Id);
                           
            boolean IsnewSalesRep = true;  //to check if Sales Rep already exists in GST            
              
           // Loop through the list and update GST record that matches to Sales Rep
           for (Sales_Team__c OpptyGST : gst){
              system.debug('GST Memebr# : ' + OpptyGST.Sales_Team_Member__c);                        
              
              //Update Sales Rep to Primary
              if (OpptyGST.Sales_Team_Member__c == Oppty.Sales_Rep__c){
                  system.debug('INSIDE If');
                  OpptyGST.Primary__c = true;
                    IsnewSalesRep = false;
                }
              // Update Sales reps to non-primary
                else if (OpptyGST.Sales_Team_Member__c != Oppty.Sales_Rep__c && OpptyGST.Primary__c == true){
                  system.debug('INSIDE else If');
                  OpptyGST.Primary__c = false;
              }
                            
              }
            
            //Add Sales Rep to GST          
             if (IsnewSalesRep == true)
             {
             Sales_Team__c newGST = new Sales_Team__c (); //instantiate the GST object to put values
                          
            newGST.Sales_Team_Member__c = Oppty.Sales_Rep__c;
             newGST.Primary__c = true;
             newGST.Opportunity__c = Oppty.Id;
             newGSTmember.add(newGST);
             insert newGSTmember;
             
              }
           
              update gst;  
                         
           }