• Manjunath S 75
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I have noticed that the Saelsforce CPQ package does an update on the parent quote record on the first navigation to EditQuoteLines page.

Create a quote and let all the AfterInsert logic fire. Keep checking the LastModifiedDate for the record.

Once all the After events have fired, and you see a consistent LastModifiedDate, navigate to add Line Items to the quote via the EditQuoteLines page.

Even without adding a product or making any calculate action (thereby triggering any custom scripts), you will notice that the LastModifiedDate changes.

This is seen on a VFRemoting log with a log line that reads:

DML_BEGIN|[620]|Op:Update|Type:SBQQ__Quote__c|Rows:1

This is the only DML I see for this transaction.

Has this been noticed by anyone? What field is getting updated here?
If we select a particular picklist value  for a field status_of_candidate ='Selected'  in "Interviewing candidates" object then the record should be automatically created in another object which is "selected candidates" using name,email and phone values. These both objects are not related to each other through look up or Master detail. Please find the below code.

trigger ifselectedcreaterecordonsc on Interviewing_Candidates__c (before insert, before update) {

list<Interviewing_Candidates__c > Sel = [select id,name, Candidate_Email__c,Status_Of_Candidate__c,c.Candidate_Phone__c from Interviewing_Candidates__c ];

list<selected_candidates__C> lst = new list<selected_candidates__C>();

for(Interviewing_Candidates__c c : sel){

if(c.Status_Of_Candidate__c == 'Selected'){

selected_candidates__C ss = new selected_candidates__C();

ss.name = c.name;
ss.Email__c =c.Candidate_Email__c;
ss.phone__C =c.Candidate_Phone__c;
 insert c;

}

}

}

Need your help
  • January 23, 2019
  • Like
  • 0
Hi All,

I want to know the basic resons for below point:

1.can we call future method into batch apex,if not why??
2.can we call futute method into anothrt future method??
Hi,
I am having this error:
FATAL_ERROR System.LimitException: SBQQ:Too many queueable jobs added to the queue: 2
when I deploy the automation of the Renewal process (I have tried  with batch size = 1,batch size = 50 and batch size = 200 nothing works ) in production (works in Sandbox), even though I have followed this article and almost have copied the batch apex class that appears in this Knowledge article: https://help.salesforce.com/articleView?id=000267468&language=en_US&type=1 .

Below is my batch apex class.The main difference to the one in the Knowledge article mentioned before is the Query at the 'start()' method, see below:
 
///***Batch Apex Class***

global class Renewal implements Database.Batchable<SObject>, Database.Stateful {
	global Integer recordsProcessed = 0;

	global Database.QueryLocator start(Database.BatchableContext bc){
		return Database.getQueryLocator(
			//This is where you input the conditions for the records which you wish to set renewal for 
			'SELECT SBQQ__RenewalForecast__c, Id FROM Contract WHERE SBQQ__RenewalForecast__c = false AND EndDate=NEXT_N_QUARTERS:2');
	}
	global void execute(Database.BatchableContext bc, List<Contract> scope){
		for(Contract contract: scope){    
            System.debug('<DEBUG> Update Renewal Forecast and Quoted for Contract: '+ contract.Id);
			contract.SBQQ__RenewalForecast__c = true;
	
			recordsProcessed = recordsProcessed + 1;

		}
        update scope;
        
        
	}
    
	global void finish(Database.BatchableContext bc){
       // Get the ID of the AsyncApexJob representing this batch job
       // from Database.BatchableContext.
       // Query the AsyncApexJob object to retrieve the current job's information.
       AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BC.getJobId()];

       // OPTIONAL: Send an email to the Apex job's submitter notifying of job completion.
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       String[] toAddresses = new String[] {a.CreatedBy.Email};
       mail.setToAddresses(toAddresses);
       mail.setSubject('Contract Renewal Batch ' + a.Status);
       mail.setPlainTextBody
       ('The batch Apex job processed ' + a.TotalJobItems +
       ' batches with '+ a.NumberOfErrors + ' failures.');
       Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }
}
This is the test class for this batch apex class, although I don't think it has any relation to the problem:
@isTest 
public class RenewalTest {
    public static testMethod void testRenewal() {
        
        // Create an Account
        Account ac = new Account();
        ac.Name = 'Jamones Corporation Number';
        ac.Type = 'Manufacturer';
        ac.Industry = 'Food';
        ac.Tiering__c = 'Tier-1';
        ac.Language__c = 'Spanish';
        insert ac;
        
        // Create an Opportunity
        Opportunity op = new Opportunity();
        op.Name= 'OriginalOpNumber';
        op.AccountId = ac.Id;
        op.Type = 'New business';
        op.StageName = 'A - Interest';
        op.CloseDate = Date.today();
        insert op;
                
        // Create the Contract
        Contract c = new Contract();
        c.StartDate = Date.today().addMonths(-8);
        c.ContractTerm = 12;
        //c.EndDate = c.StartDate.addMonths(c.ContractTerm);
        c.Status = 'draft';
        c.AccountId = ac.Id;        
        c.SBQQ__Opportunity__c = op.Id;
        c.SBQQ__RenewalForecast__c = false;
        //c.SBQQ__RenewalQuoted__c = false;
        insert c;
         
       	System.debug('<DEBUG> Contract Id:'+ String.valueOf(c.Id));
        System.debug('<DEBUG> Date of today:'+ String.valueOf(Date.today()));
        System.debug('<DEBUG> Contract Start Date:'+ String.valueOf(c.StartDate));
        System.debug('<DEBUG> Contract End Date:'+ String.valueOf(c.EndDate));
        System.debug('<DEBUG> Contract Renewal Forecast:'+ String.valueOf(c.SBQQ__RenewalForecast__c));
        //System.debug('<DEBUG> Contract Renewal Quoted:'+ String.valueOf(c.SBQQ__RenewalQuoted__c));
        
        Test.startTest();

        Renewal obj = new Renewal();
        DataBase.executeBatch(obj);
        
        Test.stopTest();
        
        Contract contract = [SELECT SBQQ__RenewalForecast__c FROM Contract WHERE Id= :c.Id];
        System.assertEquals(true, contract.SBQQ__RenewalForecast__c );
        //System.assertEquals(true, contract.SBQQ__RenewalQuoted__c ); 
    	System.debug('<DEBUG> Contract Renewal Forcast:'+ contract.SBQQ__RenewalForecast__c);
        //System.debug('<DEBUG> Contract Renewal Forcast:'+ contract.SBQQ__RenewalQuoted__c );
      }            
}

I am pretty new to salesforce but after analizing the logs the only thing that is bothering me is that there are some triggers in the Opportunity that seem to be called very frequently, and I have a suspicion they might me not 'bulkified'? However the trigger i am talking about is part of the Salesforce package 'Declarative Rollup Summary' and therefore I cannot see this part of code, so I have no idea how the triggers of this package work. See screenshots below:
User-added image
User-added image

Can anyone tell me if the fact that these triggers are called constantly is normal or not? And more importnaly, does anyone have any idea of what could be happening?

I can post more information if neeeded. 
Thanks in advance!!