• anup-prakash
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 60
    Replies
global class BatchJSToWorkdayOfferSync implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts{

	global String xmlStringxmlRes;
	global System.XmlStreamWriter xmlW;
		
   	global Database.QueryLocator start(Database.BatchableContext BC){
      	xmlW= new System.XmlStreamWriter();
      	xmlW.writeStartDocument('utf-8','1.0');
        String query = ' My QUERY';
      
      return Database.getQueryLocator(query);
      }

global void execute(Database.BatchableContext BC, List<myObject> myObjectList){

}

global void finish(Database.BatchableContext BC){
		
		xmlW.writeEndDocument(); //Close XML document
	
		xmlStringxmlRes = xmlW.getXmlString();
		System.debug('The XML :'+xmlW.getXmlString());
		xmlW.close();
		//sendEmail(xmlStringxmlRes);
	}

and I am receiving Not Serializable: System.XmlStreamWriter
Hi I get an error : "First error: Too many DML rows: 10001" when the Batch Runs.
In the schedular we have tried passing 1 as the parameter even though that doesn't seem to help..

Please Help




global class BatchSetAccountOwner implements Database.Batchable<sObject>{
global list<Account> accList = new list<Account>();
global list<Task> taskList = new list<Task>();
global list<Account> accountList = new list<Account>();
global list<Opportunity> opportunityList = new list<Opportunity>();
global list<Account> accountListToUpdate = new list<Account>();
global list<Opportunity> opportunityListToUpdate = new list<Opportunity>();
global String query;

global set<Id> excludedAccountsId = new set<Id>();
global set<Id> exculdedOpportunitiesId = new set<Id>();
global map<Id,Id> accountIdToOwnerIdMap = new map<Id,Id> ();

global Date todaysDate = Date.today();
global Date oldDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
global Date openTaskDate= todaysDate.addDays(Integer.ValueOf(System.Label.openTaskDays));
global Date threeMonthsFromTodaysDate = todaysDate.addMonths(Integer.ValueOf(System.Label.OpportunityEndMonth));
global String marketingUserId = System.label.MarketingUserID;
global List<Date> listOfDateToSelect = new List<Date>();

global Database.QueryLocator start(Database.BatchableContext BC){
  query = 'Select OwnerId, Id, Name,Type,(Select Id, CloseDate, AccountId, OwnerId, Owner.ManagerId FROM Opportunities WHERE CloseDate >= :todaysDate AND CloseDate <= :threeMonthsFromTodaysDate AND StageName != \'Closed Won\' AND StageName != \'Closed Won\') From Account WHERE OwnerId != :marketingUserId';
  System.debug('query ::'+ query);
  return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
     Integer daystoSlect = Integer.ValueOf(System.Label.OldTaskDays) +Integer.ValueOf(System.Label.openTaskDays);
     date tempDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
     for(Integer i=0; i< daystoSlect ; i++){
      tempDate = tempDate.addDays(1);
      listOfDateToSelect.add(tempDate);
     }
    
     accList = (list<Account>)scope; // TypeCast to ListOfAccount
     System.debug('accList ::'+accList);
     if(!accList.isEmpty()){
      System.debug('oldDate ::'+oldDate + 'openTaskDate ::'+openTaskDate);
      system.debug('listOfDateToSelect ::' + listOfDateToSelect);
     
      taskList = [SELECT AccountId, ActivityDate, WhatId, WhoId, isClosed FROM Task WHERE ActivityDate != null AND ActivityDate IN :listOfDateToSelect AND AccountId !=null AND Account.OwnerId !=:marketingUserId];
      System.debug('taskList ::'+taskList);
      for(Account accObj : accList){
       System.debug('accObj ::'+accObj);
      
       // Work For Tasks
       if(!taskList.isEmpty()){
        for(Task task : taskList){
         //system.debug( 'oldDate' +oldDate+ 'openTaskDate' +openTaskDate);
         DateTime dt = task.ActivityDate;
         Date taskActivityDate = dt.Date();
        
         if(task.AccountId == accObj.Id && ((taskActivityDate >oldDate && task.IsClosed) || (taskActivityDate < openTaskDate && taskActivityDate > todaysDate && task.IsClosed==false))){
          system.debug( 'taskActivityDate ::' +taskActivityDate);
          system.debug('task.AccountId ::'+task.AccountId);
          excludedAccountsId.add(task.AccountId);
         }
        }
       }
      
       // Work For Opportunities
       if(accObj.Opportunities.size() > 0){
        for(Opportunity opp : accObj.Opportunities){
         excludedAccountsId.add(opp.AccountId);
         //exculdedOpportunitiesId.add(opp.Id);
        }
       }
      
       // Exclude Accounts of type Subscriber
       if(accObj.Type == 'Subscriber'){
        excludedAccountsId.add(accObj.Id);
       }
      }
     
      System.debug('excludedAccountsId ::'+excludedAccountsId);
      accountList = [Select OwnerId from Account Where Id Not IN :excludedAccountsId ];
      System.debug('accountList to Update :: ' + accountList);
      //opportunityList = [SELECT o.OwnerId, o.Owner.ManagerId FROM Opportunity o WHERE Id NOT IN :exculdedOpportunitiesId];
     
      for(Account acc : accountList){
       acc.OwnerId = marketingUserId;
       System.debug('***marketingUserId*****'+ marketingUserId);
       system.debug('*****acc.OwnerId******'+ acc.OwnerId);
       accountListToUpdate.add(acc);
      }
     
      /*for(Opportunity opp : opportunityList){
       if(opp.Owner.ManagerId !=null){
        system.debug('***Opp Owner Manager**' + opp.Owner.ManagerId);
        opp.OwnerId = opp.Owner.ManagerId;
        opportunityListToUpdate.add(opp);
       }
      }*/
     
      try{
       update accountListToUpdate;
       System.debug('***accountListToUpdate***'+ accountListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
     
      /*
      try{
       update opportunityListToUpdate;
       System.debug('***opportunityListToUpdate***'+ opportunityListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
      */ 
     }
    }
    global void finish(Database.BatchableContext BC){
     System.debug('*******************FINISH**********************');
    }
   
}

https://success.salesforce.com/0693000000325re

 

Please Help. A screen Shot Is attached of what I wish to re order.. I wish to re-order the Data Category Group.. 

Hi I have the Articles in the related list of cases and it has the "Find articles " in the sidebar component which comprises of Picklists.

 

I want to rearrange these picklist in a particular order.. Any Help..  

Hi I am facing trouble to set values in wrapper class.. I don't know what is happening.. or what I am missing that its not setting the values.. Ny help!!

Hi I have a requirement in which I have to give a lookup to user.. and I have given the create permission to a user but that user is not able to see the users List.. How to resolve?

Hi

 

            I was facing a telephonic round of an interview and the interviewer had asked me this question.. I tried to ask people working for over 2 years on salesforce and a team Lead as well but couldn't find the answer.. So here I am.. where I've always got the help, when looked for.. So here Is the Question

 

Int: can we  use use Multiple extensions?

Me: Yes, we can.

Int: we have three extensions ext1, ext2, ext3.. and all of them have the method Method1.. and I call this method  in a VFPage whose method will be called..

Me: The one which is on he left most side.

Int: I want to call the Method of Ext2/Ext3.. How will I do so?

Me: Numb!! Job Gone!! Me yet Jobless..  :(

 

 

Hi I have a vfPage and it has three command buttons to rerender the three output panels containing textboxes.. and I want to make these textboxes required on the basis of the output panel being selected via the command button selection..

Action region not helping

Hi I have writen a trigger and it is not achieving what I want it to achieve.

 

I have a master-detail relation between a Prod__c(Master) and Prod_Detail__c (Detail)

Prod__c  has the following Fields:

Name,

Manufacturer__c

Description__c

 

Prod_Detail__c has the following Fields:

Prod__c (reference)

Name (labeled Lot Name)

Quantity__c

______________________________

 

what I am wanting to do with the help of trigger is to check if there is a duplicate entry on Prod_Detail__c  if there is then

It should update the quantity sum .. in case of insert as well as update.. this is what I have written but its still adding a duplicate record record and updating the field as well. I am stuck..

trigger CheckDuplicateBatchNumber on Prod_Detail__c (before insert, before update) {
	
	map<String, Prod_Detail__c> pdMap = new map<String, Prod_Detail__c>();  // map of match number to product name
	
	//check Duplicate Entry
	for(Prod_Detail__c pd : Trigger.new){
		if(trigger.isInsert || trigger.oldmap.get(pd.id).Name != pd.Name){
			String pdName = pd.Name.toUpperCase();
			if(!(pdMap.containskey(pdName))){

				pdMap.put(pdName,pd);
			}
			else if(pdMap.containskey(pdName)){ //update Quantity
				Prod_Detail__c pdObject = new Prod_Detail__c();
				pdObject = pdMap.get(pdName);
				pdObject.Quantity__c = pd.Quantity__c + pdObject.Quantity__c ;
				pdMap.put(pdName,pdObject);
			}
		}
	}
	
	list<Prod_Detail__c> upsertList = new list<Prod_Detail__c>();
	
	if(pdMap.size()!= Null){
		for(String pName : pdMap.keyset()){ 
			for(Prod_Detail__c pd: [Select ID, Name, Quantity__c, MRP__c, Prod__c, Unit_Price__c from Prod_Detail__c where Name IN :pdMap.keySet()]){
				if((pd.Name.equalsIgnoreCase(pName))&&(pd.Prod__c == pdMap.get(pName).Prod__c)){
					pd.Quantity__c = pd.Quantity__c + pdMap.get(pName).Quantity__c ;
					pd.Name = pd.name.toUpperCase();
					upsertList.add(pd);
					continue;
					
				}
				else {
					String nam;
					Prod_Detail__c pOb = pdMap.get(pName);
					nam = pOb.Name.toUpperCase();
					pOb.Name = nam;
					upsertList.add(pOb);
				}
			}
		}
		upsert(upsertList);
	} 
}

 

Hi I have a master detail relationship between Product__c and Product_Detail__c and I want to stop duplicate entry in the Product_detail__c and ensure that iff a user is trying to enter data into the Within Product with exixting Name of Detail record then the Quantity field of the detail should be totalled leaving the rest unaltered..

 

Product__c Fields :

Name
Description__c
ManufacturerName__c

----------------------------------

Product_Detail__c Fields:


Name,

Quantity__c,

MRP__c,

Unit_Price__c,

Product__c -> reference

____________________

 

 

Hi.

 

   I have written just a few triggers and was wondering if this trigger is absolutely fine or if it lacks something.. although the trigger is working when i am inserting single entry through the window.. was wondering if it would also work when using data Loader.

Hi what I am trying to attain in my page is that I Have three comandbuttons "New Product", "Add Lot" , "Search Productt"

and when a user clicks on either of the buttons the related set of entities should be displayed.. Instead of re directing the user to a different page I want it to happen on this page itself.. I do not wish to use Iframe.. Is there any way?

 

The javascript is not working no matter what.. I have been quite troubled now...

 

<apex:page controller="UploadFileController" >

<apex:form id="formID" >
       <apex:pageBlock id="pageBlockID">
           <apex:pageBlockButtons >
               <apex:commandButton action="{!saveAttachment}" value="Upload File"/>
           </apex:pageBlockButtons>
           <apex:pageBlockSection columns="1" id="pageBlockSectionID" >
               <apex:pageBlockSectionItem >
                   <apex:outputLabel value="Division" />
                   <apex:selectList multiselect="false" required="true" size="1" value="{!divisionID}">
                       <apex:selectOptions value="{!divisionList}"></apex:selectOptions>
                   </apex:selectList>
               </apex:pageBlockSectionItem>
               <apex:pageblocksectionItem >
                    <apex:outputlabel value="Fiscal Year" />
                    <apex:inputText value="{!fiscalYearName}" id="fiscID" onchange="checkExtension();"/>
               </apex:pageblocksectionItem>
               <apex:pageBlockSectionItem >
                   <apex:outputlabel value="File" />
                   <apex:inputFile accept="pdf,jpg" fileName="{!attachmentFile.name}" value="{!attachmentFile.body}" id="attachmentFileID" onchange="checkExtension();" />
               </apex:pageBlockSectionItem>
               
               <apex:pageBlockSectionItem >
                   <apex:outputLabel value="To Account"/>
                   <apex:selectList value="{!accountID}" multiselect="false" size="1">
                       <apex:selectOptions value="{!accountList}" />
                   </apex:selectList>
               </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
       </apex:pageBlock>
   </apex:form>
<script>
    function checkExtension(){
        var x = document.getElementById('{!$Component.formID.pageBlockID.pageBlockSectionID.attachmentFileID}').value;
        alert(x);
    }
</script>
</apex:page>

Hi I have been working on salesforce for quite a while now. Despite that I consider myself as a beginner.. Can you Please give me scenarios as to where I will have to use sets and Maps.. I have used Lists and I am comfortable with It but I have never faced a scenario as to when I have to use a Map and Set in differnt scenerio.. so that I could help me to understand the usage of these two collection elements..

 

 

 

Hi

 

I am displaying data in a pageblock table and it is retrieving data on basis of a soql query.. I have two different custom objects BillingJunction__c and Product__c I am trying to write a query like this..

 

Select (select name__c from product__c where id = :Product_ID__c),Product_ID__c,Product_Qty__c, Sold_Price__c from BillingJunction__c where Customer_ID__c = :custID AND Bill_ID__c = :billID ]

 

where BillingJuction also stores the productID and I want to retrive the name as it has the ID

Hi I have a Situation here..

 

I have a billing custom object that has a relationship to customer custom object..  and then I have a product custom object and a tempbilling custom object that stores the productID, QTY, Bill ID, customerID..   I have created a visualforce page that allows a person to select a customer and then he selects the products and which is totaled. but I am facing dificulty to manage the databse.. the calulation is working fine but I am facing dificulty to manage the database..

 I want to do is that if I insert into bill the customerID then how can I get the ID of the bill after insert so that I could use it further?

currently what I have implemented is that a person selects a single Item in a select list and  once clicks sublit the outputpanel fields are ... but I do not wish to use the submit /comand uton.. is there a way by which I can rerender the output panel onchange event of the select list.

Hi what I am trying to do is that to Display the Names Of all Accounts as a command lInk and when the Specific account name is clicked then the related List of its contact should POP up on a different page.. How can I achieve this?

hi i have three custom objects bills customers and products and what I am trying to do is that when we create a bill it should be populated on the customers related list.. And the bill should contain the related products on the .. there can be multiple products and it won't be possible to create a new product on every bill we should be able to select multiple products for a bill . how can we achieve this...

in my VF-Page i am trying to enable inlineeditsupport for the data displayed in pageblocktable works fine iff data is present in all fields.. if a particular field is blank in a record then the inlineeditsupport doesn't allow to edit that empty/null field.. how to overcome this problem..

 

Thanks In Advance..

 

Anup Prakash

Hi I get an error : "First error: Too many DML rows: 10001" when the Batch Runs.
In the schedular we have tried passing 1 as the parameter even though that doesn't seem to help..

Please Help




global class BatchSetAccountOwner implements Database.Batchable<sObject>{
global list<Account> accList = new list<Account>();
global list<Task> taskList = new list<Task>();
global list<Account> accountList = new list<Account>();
global list<Opportunity> opportunityList = new list<Opportunity>();
global list<Account> accountListToUpdate = new list<Account>();
global list<Opportunity> opportunityListToUpdate = new list<Opportunity>();
global String query;

global set<Id> excludedAccountsId = new set<Id>();
global set<Id> exculdedOpportunitiesId = new set<Id>();
global map<Id,Id> accountIdToOwnerIdMap = new map<Id,Id> ();

global Date todaysDate = Date.today();
global Date oldDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
global Date openTaskDate= todaysDate.addDays(Integer.ValueOf(System.Label.openTaskDays));
global Date threeMonthsFromTodaysDate = todaysDate.addMonths(Integer.ValueOf(System.Label.OpportunityEndMonth));
global String marketingUserId = System.label.MarketingUserID;
global List<Date> listOfDateToSelect = new List<Date>();

global Database.QueryLocator start(Database.BatchableContext BC){
  query = 'Select OwnerId, Id, Name,Type,(Select Id, CloseDate, AccountId, OwnerId, Owner.ManagerId FROM Opportunities WHERE CloseDate >= :todaysDate AND CloseDate <= :threeMonthsFromTodaysDate AND StageName != \'Closed Won\' AND StageName != \'Closed Won\') From Account WHERE OwnerId != :marketingUserId';
  System.debug('query ::'+ query);
  return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
     Integer daystoSlect = Integer.ValueOf(System.Label.OldTaskDays) +Integer.ValueOf(System.Label.openTaskDays);
     date tempDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
     for(Integer i=0; i< daystoSlect ; i++){
      tempDate = tempDate.addDays(1);
      listOfDateToSelect.add(tempDate);
     }
    
     accList = (list<Account>)scope; // TypeCast to ListOfAccount
     System.debug('accList ::'+accList);
     if(!accList.isEmpty()){
      System.debug('oldDate ::'+oldDate + 'openTaskDate ::'+openTaskDate);
      system.debug('listOfDateToSelect ::' + listOfDateToSelect);
     
      taskList = [SELECT AccountId, ActivityDate, WhatId, WhoId, isClosed FROM Task WHERE ActivityDate != null AND ActivityDate IN :listOfDateToSelect AND AccountId !=null AND Account.OwnerId !=:marketingUserId];
      System.debug('taskList ::'+taskList);
      for(Account accObj : accList){
       System.debug('accObj ::'+accObj);
      
       // Work For Tasks
       if(!taskList.isEmpty()){
        for(Task task : taskList){
         //system.debug( 'oldDate' +oldDate+ 'openTaskDate' +openTaskDate);
         DateTime dt = task.ActivityDate;
         Date taskActivityDate = dt.Date();
        
         if(task.AccountId == accObj.Id && ((taskActivityDate >oldDate && task.IsClosed) || (taskActivityDate < openTaskDate && taskActivityDate > todaysDate && task.IsClosed==false))){
          system.debug( 'taskActivityDate ::' +taskActivityDate);
          system.debug('task.AccountId ::'+task.AccountId);
          excludedAccountsId.add(task.AccountId);
         }
        }
       }
      
       // Work For Opportunities
       if(accObj.Opportunities.size() > 0){
        for(Opportunity opp : accObj.Opportunities){
         excludedAccountsId.add(opp.AccountId);
         //exculdedOpportunitiesId.add(opp.Id);
        }
       }
      
       // Exclude Accounts of type Subscriber
       if(accObj.Type == 'Subscriber'){
        excludedAccountsId.add(accObj.Id);
       }
      }
     
      System.debug('excludedAccountsId ::'+excludedAccountsId);
      accountList = [Select OwnerId from Account Where Id Not IN :excludedAccountsId ];
      System.debug('accountList to Update :: ' + accountList);
      //opportunityList = [SELECT o.OwnerId, o.Owner.ManagerId FROM Opportunity o WHERE Id NOT IN :exculdedOpportunitiesId];
     
      for(Account acc : accountList){
       acc.OwnerId = marketingUserId;
       System.debug('***marketingUserId*****'+ marketingUserId);
       system.debug('*****acc.OwnerId******'+ acc.OwnerId);
       accountListToUpdate.add(acc);
      }
     
      /*for(Opportunity opp : opportunityList){
       if(opp.Owner.ManagerId !=null){
        system.debug('***Opp Owner Manager**' + opp.Owner.ManagerId);
        opp.OwnerId = opp.Owner.ManagerId;
        opportunityListToUpdate.add(opp);
       }
      }*/
     
      try{
       update accountListToUpdate;
       System.debug('***accountListToUpdate***'+ accountListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
     
      /*
      try{
       update opportunityListToUpdate;
       System.debug('***opportunityListToUpdate***'+ opportunityListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
      */ 
     }
    }
    global void finish(Database.BatchableContext BC){
     System.debug('*******************FINISH**********************');
    }
   
}

Hi

 

            I was facing a telephonic round of an interview and the interviewer had asked me this question.. I tried to ask people working for over 2 years on salesforce and a team Lead as well but couldn't find the answer.. So here I am.. where I've always got the help, when looked for.. So here Is the Question

 

Int: can we  use use Multiple extensions?

Me: Yes, we can.

Int: we have three extensions ext1, ext2, ext3.. and all of them have the method Method1.. and I call this method  in a VFPage whose method will be called..

Me: The one which is on he left most side.

Int: I want to call the Method of Ext2/Ext3.. How will I do so?

Me: Numb!! Job Gone!! Me yet Jobless..  :(

 

 

global class BatchJSToWorkdayOfferSync implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts{

	global String xmlStringxmlRes;
	global System.XmlStreamWriter xmlW;
		
   	global Database.QueryLocator start(Database.BatchableContext BC){
      	xmlW= new System.XmlStreamWriter();
      	xmlW.writeStartDocument('utf-8','1.0');
        String query = ' My QUERY';
      
      return Database.getQueryLocator(query);
      }

global void execute(Database.BatchableContext BC, List<myObject> myObjectList){

}

global void finish(Database.BatchableContext BC){
		
		xmlW.writeEndDocument(); //Close XML document
	
		xmlStringxmlRes = xmlW.getXmlString();
		System.debug('The XML :'+xmlW.getXmlString());
		xmlW.close();
		//sendEmail(xmlStringxmlRes);
	}

and I am receiving Not Serializable: System.XmlStreamWriter
I have two VF pages. They are both controlled by an Apex class. The first page has many prepopulated fields that the user can change. The second page is a differently layed out page using the updated data but saved as a PDF attachment. I would post but it's over 1000 lines of code.

My situation/question is this:
The user edits the first VF page and clicks submit. Once the data passes some sanity checks it is saved. I can see all of these saved values in the Apex controller in the System.debug logs I generate. All values are the expected values from the user edits.
However, when I generate/save the PDF, all the values are correct *except* the values from two picklists (which are country code address single picklists). These values appear in the PDF page as the value that was previously on the user editable page (in other words, the value *before* the user edited the page). The strange thing is that when I look at the incorrect values/variables in the debug, they are the update values. I am calling the PDF generation code immediately after the above mentioned System.debug.
So, does anyone have an idea why the original values from the first VF page are used instead of the updated values I see in the logs? All the other values are the updated values.

I can try to post code snippets if needed but it's a lot to post here. 
Hi I get an error : "First error: Too many DML rows: 10001" when the Batch Runs.
In the schedular we have tried passing 1 as the parameter even though that doesn't seem to help..

Please Help




global class BatchSetAccountOwner implements Database.Batchable<sObject>{
global list<Account> accList = new list<Account>();
global list<Task> taskList = new list<Task>();
global list<Account> accountList = new list<Account>();
global list<Opportunity> opportunityList = new list<Opportunity>();
global list<Account> accountListToUpdate = new list<Account>();
global list<Opportunity> opportunityListToUpdate = new list<Opportunity>();
global String query;

global set<Id> excludedAccountsId = new set<Id>();
global set<Id> exculdedOpportunitiesId = new set<Id>();
global map<Id,Id> accountIdToOwnerIdMap = new map<Id,Id> ();

global Date todaysDate = Date.today();
global Date oldDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
global Date openTaskDate= todaysDate.addDays(Integer.ValueOf(System.Label.openTaskDays));
global Date threeMonthsFromTodaysDate = todaysDate.addMonths(Integer.ValueOf(System.Label.OpportunityEndMonth));
global String marketingUserId = System.label.MarketingUserID;
global List<Date> listOfDateToSelect = new List<Date>();

global Database.QueryLocator start(Database.BatchableContext BC){
  query = 'Select OwnerId, Id, Name,Type,(Select Id, CloseDate, AccountId, OwnerId, Owner.ManagerId FROM Opportunities WHERE CloseDate >= :todaysDate AND CloseDate <= :threeMonthsFromTodaysDate AND StageName != \'Closed Won\' AND StageName != \'Closed Won\') From Account WHERE OwnerId != :marketingUserId';
  System.debug('query ::'+ query);
  return Database.getQueryLocator(query);
    }
   
    global void execute(Database.BatchableContext BC, List<sObject> scope){
     Integer daystoSlect = Integer.ValueOf(System.Label.OldTaskDays) +Integer.ValueOf(System.Label.openTaskDays);
     date tempDate = todaysDate.addDays(-Integer.ValueOf(System.Label.OldTaskDays));
     for(Integer i=0; i< daystoSlect ; i++){
      tempDate = tempDate.addDays(1);
      listOfDateToSelect.add(tempDate);
     }
    
     accList = (list<Account>)scope; // TypeCast to ListOfAccount
     System.debug('accList ::'+accList);
     if(!accList.isEmpty()){
      System.debug('oldDate ::'+oldDate + 'openTaskDate ::'+openTaskDate);
      system.debug('listOfDateToSelect ::' + listOfDateToSelect);
     
      taskList = [SELECT AccountId, ActivityDate, WhatId, WhoId, isClosed FROM Task WHERE ActivityDate != null AND ActivityDate IN :listOfDateToSelect AND AccountId !=null AND Account.OwnerId !=:marketingUserId];
      System.debug('taskList ::'+taskList);
      for(Account accObj : accList){
       System.debug('accObj ::'+accObj);
      
       // Work For Tasks
       if(!taskList.isEmpty()){
        for(Task task : taskList){
         //system.debug( 'oldDate' +oldDate+ 'openTaskDate' +openTaskDate);
         DateTime dt = task.ActivityDate;
         Date taskActivityDate = dt.Date();
        
         if(task.AccountId == accObj.Id && ((taskActivityDate >oldDate && task.IsClosed) || (taskActivityDate < openTaskDate && taskActivityDate > todaysDate && task.IsClosed==false))){
          system.debug( 'taskActivityDate ::' +taskActivityDate);
          system.debug('task.AccountId ::'+task.AccountId);
          excludedAccountsId.add(task.AccountId);
         }
        }
       }
      
       // Work For Opportunities
       if(accObj.Opportunities.size() > 0){
        for(Opportunity opp : accObj.Opportunities){
         excludedAccountsId.add(opp.AccountId);
         //exculdedOpportunitiesId.add(opp.Id);
        }
       }
      
       // Exclude Accounts of type Subscriber
       if(accObj.Type == 'Subscriber'){
        excludedAccountsId.add(accObj.Id);
       }
      }
     
      System.debug('excludedAccountsId ::'+excludedAccountsId);
      accountList = [Select OwnerId from Account Where Id Not IN :excludedAccountsId ];
      System.debug('accountList to Update :: ' + accountList);
      //opportunityList = [SELECT o.OwnerId, o.Owner.ManagerId FROM Opportunity o WHERE Id NOT IN :exculdedOpportunitiesId];
     
      for(Account acc : accountList){
       acc.OwnerId = marketingUserId;
       System.debug('***marketingUserId*****'+ marketingUserId);
       system.debug('*****acc.OwnerId******'+ acc.OwnerId);
       accountListToUpdate.add(acc);
      }
     
      /*for(Opportunity opp : opportunityList){
       if(opp.Owner.ManagerId !=null){
        system.debug('***Opp Owner Manager**' + opp.Owner.ManagerId);
        opp.OwnerId = opp.Owner.ManagerId;
        opportunityListToUpdate.add(opp);
       }
      }*/
     
      try{
       update accountListToUpdate;
       System.debug('***accountListToUpdate***'+ accountListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
     
      /*
      try{
       update opportunityListToUpdate;
       System.debug('***opportunityListToUpdate***'+ opportunityListToUpdate);
      }catch(Exception ex){
       system.debug('*********' +ex.getMessage());
      }
      */ 
     }
    }
    global void finish(Database.BatchableContext BC){
     System.debug('*******************FINISH**********************');
    }
   
}

I only have 74% Code coverage & at a loss on how to resolve in order to load my updated code

I have expanded my Apex class to cover more 'trigger' scenarios in our Sandbox and cannot deploy to Production because I only have 74% code coverage. The code automatically creates 'Project Activities' based on answers to four questions defined on the parent 'Engineering Project' header object. I also expanded the trigger test criteria to cover all appropriate scenarios but get the following error when I try to deploy both classes. 
 
Deployment Error
 
EngineeringProjectTriggerTest.myUnitTest() Class 118 Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Class.ProjectActivityHelper.buildActivitiesDependantOnProject: line 118, column 1 Class.ProjectActivityHelper.buildActivityList: line 88, column 1 Class.EngineeringProjectTriggerTest.myUnitTest: line 166, column 1"

Should mention I am new to Apex & building on code previously created by a SF consultant however the code itself has tested successfully in our Sandbox and is doing what I need it to do. The only problem I have is deploying the amended code to production.
 
Unfortunately I can't post my Apex classes as there are too many characters however I hope someone can help provide a novice with some guidance on what to do next!
 
  • August 18, 2013
  • Like
  • 0

Hi I am facing trouble to set values in wrapper class.. I don't know what is happening.. or what I am missing that its not setting the values.. Ny help!!

Hi I have a requirement in which I have to give a lookup to user.. and I have given the create permission to a user but that user is not able to see the users List.. How to resolve?

Hi

 

            I was facing a telephonic round of an interview and the interviewer had asked me this question.. I tried to ask people working for over 2 years on salesforce and a team Lead as well but couldn't find the answer.. So here I am.. where I've always got the help, when looked for.. So here Is the Question

 

Int: can we  use use Multiple extensions?

Me: Yes, we can.

Int: we have three extensions ext1, ext2, ext3.. and all of them have the method Method1.. and I call this method  in a VFPage whose method will be called..

Me: The one which is on he left most side.

Int: I want to call the Method of Ext2/Ext3.. How will I do so?

Me: Numb!! Job Gone!! Me yet Jobless..  :(

 

 

Hi people,

 

Today I faced with interesting problem. When I try to Compile all classes I have a 'nice' error 'Maximum view state size limit (135KB) exceeded.'.

 

Did someone have this kind of problem? If so, how to solve this issue?

 

Thanks in advance.