• Kevin Antonioli 4
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
My question is Salesforce CPQ related. When Order Products are created, we have a need to retain the Start Date of their associated quote lines under the following scenario: coterm 2 contracts where the master contract has a later End Date than the other contract. What is happening in this scenario is the subscriptions from the 2 contracts are getting created as quote lines with the correct dates, but when Order Products are created from those quote lines upon ordering the Opportunity, the start dates of some of those order products is pushed out into the future by the difference in end dates between the master contract and the contract cotermed with it.

CPQ and/or Billing Package Version provided for the affected org. 
214.12

Master Contract end date: 10/13/2014
Non-Master Contract end date: 7/21/2014
Difference in end dates between these contracts: 84 days (make note of this value as I'll reference it again below)

Regarding the Order created from ordering the resulting renewal opportunity: all of this Order's Order Product start dates are not the desired values.

Properties of one of the problematic Order Products:
Start Date: 1/6/2015 which is not desired. This is being calculated, by what appears to be CPQ managed code, as follows: Master Contract End Date + the difference in end dates between the Master Contract and non-master Contract (84) + 1. CPQ is essentially pushing the start date out in advance, instead of getting it from the quote line.
Effective Start Date of associated quote line: 10/14/2014 (1 day past the Master Contract End Date). This is the desired start date for the quote line's associated Order Product.

We have already read through the relevant Salesforce documentation:
https://help.salesforce.com/articleView?id=cpq_order_date_logic.htm&type=5

We have already opened a case as well to assess the risk of writing custom apex to override the Order Product dates upon Order Product creation. On the case, Salesforce advised to post a question here. So my question is, what are the risks/implications of overriding the Order Product dates with custom Apex, in a before insert trigger context? Note: we do not have Salesforce Billing installed.

Thanks,
-Kevin

 

I have code in production that passes all unit tests and works fine in most cases but in some instances I am getting an Invalid Query Locator error and I can't figure out why.

 

 

My code is a custom rollup trigger that  triggers when a case is 'Closed'.  Rolling up data from cases to their parent accounts.

 

 

My code loops through trigger.new to collect the accountid associated with each case that has just closed.  It then loops through the list of accounts pulling and account record and any associated cases.  Finally it loops through the accounts, loops through each account's cases, and adds up all of the appropriate values depositing the result into fields within the Account then updates the account.  A simple rollup really.

 

 

This works fine most of the time but I have come across some accounts that fail this process, it doesn't matter which case is closed on the account, I always get the same error so the problem is with the account not with the case.  This account has roughly 340 closed cases, though I don't believe that is anywhere near any kind of limit.

 

 

To get to my point, I'm not sure what 'Invalid Query Locator' means in this particular case.  I have seen very little info about the Query Locator, all of it old, but it all suggests problems that occur when querys time out or have been 'garbage collected'.  In this case the error comes back immediately so timeout or memory cleanup should not be an issue.

 

 

 

Below is the relevant code, it's chopped to remove specific custom field names and such so it's pretty ugly.

 

Any help is greatly appreciated.

 

Many Thanks

Jon

 

 

 

 

//if the given trigger has just been closed then roll up the FQTD follup values

set<ID> FQTDAccountIDs = new set<ID>(); //list of Accounts involved with fqtd rollup calculations
map<ID, Account> AccountsToUpdate = new map<ID, Account>(); //the accounts that will be updated by this trigger


//prepare for FQTD rollup

Integer i = 0;
for(case theCase : trigger.new)//loop through all of the available records in the trigger
{
if((trigger.old[i].status != 'Closed') && (trigger.new[i].status == 'Closed'))
{
if(!FQTDAccountIDs.contains(trigger.new[i].accountid))
{
FQTDAccountIDs.add(trigger.new[i].accountid);
System.Debug('Adding Account to the FQTD List: ' + trigger.new[i].accountid);
}
}
i++;
}


//ok, so we may have a list of records to update, lets get to the action
if(FQTDAccountIDs.size() > 0) //do we have any records to update?
{

 

  //loop through all accounts and add them, with their cases, to a map for later looping

for(Account thisAccount : [Select Id, name, (Select casenumber, status From Cases where status = 'Closed') From Account where id in :FQTDAccountIDs])
{
AccountsToUpdate.put(thisAccount.id, thisAccount);
}


//loop through each specified account
for(Account currentAccount : AccountsToUpdate.values())
{




// ****** This next for loop is the apparent problem; System.Exception: invalid query locator ********

//loop through all cases associated with this account
for(Case theCase : currentAccount.Cases)
{

//calculate the fields and rollup the data
// currentAccount.rolledupfield += theCase.rollupfield1__c + theCase.rollupfield2__c
}



}


//update the Accounts with the new values
update AccountsToUpdate.values();



}