• Matt Webber 20
  • NEWBIE
  • 20 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi all,

I'm working on this class mainly for my own development. There's likely to be a simpler declarative solution but I'm trying to solve the problem with code.

My error message is this:
First error: SObject row was retrieved via SOQL without querying the requested field: SBQQ__Quote__c.SBQQ__Opportunity2__r

Here's my code:

public class UpdateQuotesWithInactiveSalesUser implements Database.Batchable<sObject> {
 
   
 
   public Database.QueryLocator start(Database.BatchableContext bc) {
 
 
 
       return Database.getQueryLocator('SELECT SBQQ__SalesRep__c, Id FROM SBQQ__Quote__c WHERE SBQQ__SalesRep__r.IsActive = FALSE AND (SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Needs Analysis\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Proposal\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Proposal Sent\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Negotiation\')');
   }
  
   public void execute(Database.BatchableContext BC, list<SBQQ__Quote__c> quotesWithInactiveSalesRep){
  
 
  
 
//only 50000 lines can be returned from the SOQL query
 
//Loop through those quotes and set SalesRep to match whoever is Opportunity Owner
 
for(SBQQ__Quote__c quote: quotesWithInactiveSalesRep){
    quote.SBQQ__SalesRep__c = quote.SBQQ__Opportunity2__r.OwnerId;
}
 
update quotesWithInactiveSalesRep;
 
   }
 
 
 
public void finish(Database.BatchableContext BC){
 
 
//you need to update the list not the variable or the class
//Run a DML update statement, now all quote records in the list will have sales rep updated to be the same as the //opportunity owner
 
}
 
//single update and single query so should avoid governor limits
 
//gov limit you're most likely to hit is the maximum CPU time - that can depend how much automation you have on //the quote object because that affects the calculation
 
}


What I'm trying to do:
I want to update all quotes where the user in the sales rep field on quote is inactive and update that field to be whoever is the owner of the related opportunity. But only if the opportunity can be worked so only if the related opp is at the stages named in the query (not closed won or closed lost).
Currently I'm just seeing that error message in the Apex Jobs and my test quote that meets the conditions isn't being updated (and still has the inactive user in the sales rep field).


Sorry for the long message, this is my first time using this site. Thanks very much in advance for any help I can get with this.

Best wishes,

Matt

Hi all,

I'm trying to add a formula as a resource in a Flow and I keep getting syntax errors. It's a really basic formula that will be referenced by an Outcome and is basically going to make the Flow take one of 2 paths depending on whether or not a checkbox on the Account has been checked or not. Many thanks to anyone that can help me. I've already specified the data type to be Boolean and this formula is used in a decision that follows a Get Records element that collects all Account field data from the account record that triggered the Flow.

IF( 
{!Get_Account_Details.Ringfenced__c}, 'True'
)

In my decision element, I'm basically going to end the flow with a message if the checkbox is checked and allow the flow to continue on its path, if the checkbox is unchecked. 

Any other details needed, please let me know.

Thanks in advance,

Matt

Hi all,

I'm working on this class mainly for my own development. There's likely to be a simpler declarative solution but I'm trying to solve the problem with code.

My error message is this:
First error: SObject row was retrieved via SOQL without querying the requested field: SBQQ__Quote__c.SBQQ__Opportunity2__r

Here's my code:

public class UpdateQuotesWithInactiveSalesUser implements Database.Batchable<sObject> {
 
   
 
   public Database.QueryLocator start(Database.BatchableContext bc) {
 
 
 
       return Database.getQueryLocator('SELECT SBQQ__SalesRep__c, Id FROM SBQQ__Quote__c WHERE SBQQ__SalesRep__r.IsActive = FALSE AND (SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Needs Analysis\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Proposal\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Proposal Sent\' OR SBQQ__Quote__c.SBQQ__Opportunity2__r.StageName = \'Negotiation\')');
   }
  
   public void execute(Database.BatchableContext BC, list<SBQQ__Quote__c> quotesWithInactiveSalesRep){
  
 
  
 
//only 50000 lines can be returned from the SOQL query
 
//Loop through those quotes and set SalesRep to match whoever is Opportunity Owner
 
for(SBQQ__Quote__c quote: quotesWithInactiveSalesRep){
    quote.SBQQ__SalesRep__c = quote.SBQQ__Opportunity2__r.OwnerId;
}
 
update quotesWithInactiveSalesRep;
 
   }
 
 
 
public void finish(Database.BatchableContext BC){
 
 
//you need to update the list not the variable or the class
//Run a DML update statement, now all quote records in the list will have sales rep updated to be the same as the //opportunity owner
 
}
 
//single update and single query so should avoid governor limits
 
//gov limit you're most likely to hit is the maximum CPU time - that can depend how much automation you have on //the quote object because that affects the calculation
 
}


What I'm trying to do:
I want to update all quotes where the user in the sales rep field on quote is inactive and update that field to be whoever is the owner of the related opportunity. But only if the opportunity can be worked so only if the related opp is at the stages named in the query (not closed won or closed lost).
Currently I'm just seeing that error message in the Apex Jobs and my test quote that meets the conditions isn't being updated (and still has the inactive user in the sales rep field).


Sorry for the long message, this is my first time using this site. Thanks very much in advance for any help I can get with this.

Best wishes,

Matt