function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AngelikaAngelika 

How do I get a flow to realize that it needs to pull information from an apex scheduler?

I am new to apex and have built an apex schedule class that runs everyday. If an account has an account review date for commissions is two weeks (14 days) away the scheduler will send an email to our Sales Department. The email contains a link to a flow. The flow starts a process to calculate the new commission. To do that, the flow needs to understand to pull information from the account that triggered the email to be sent, the account that has an account review date in 2weeks.

 

Currently, the email sends out fine with the link to the flow. The link to the flow works, but once you get to the flow, the flow does not know/understand what account it should be pulling information from. I’m not sure if I need to alter my code in my scheduler and/or the code in my flow.

 

Here is how the flow is accessing information:

 

Before the first screen, a record lookup in flow occurs. It pulls the information from the account ID and a variable, vaAccountID. I think that the variable {!vaAccountID} is populated with the AccountID that is linked to the commission. (I didn’t make this flow. I’m not 100% sure

 

 

 

 

 

 

 

When I run my scheduler, I have it determine if there is an account with an account review date based upon the account Id. It sends the email template with the flow link to the sales department.

 

The scheduler sends the email and is “happy”. The criteria it needs to execute the method is complete (there is an account with an account review date 14 days from now and it sends the email).

global class AccountReviewSchedulerEmailAcc implements Schedulable{
global void execute (SchedulableContext ctx)
{

sendEmail();

}
public void sendEmail()
{

for(Account acc : [SELECT Id FROM Account WHERE Next_Account_Review_Date__c = : system.Today().addDays(14)])
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId('00XF0000000LfE0');
mail.setTargetObjectId('005J0000000JWYx');
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });
}
}


}

 

The flow however, is not “happy”. It does not know what account to pull information from.

 

In the first screen of the flow, it’s supposed to show the recurring revenue and link to the account page. The recurring revenue field is blank. The link to account page does not work.

 

If I try to advance past the first screen of the flow, I get a generic error screen from Salesforce and a detailed error message from Salesforce. It says:

 

Encountered unhandled fault when running process Organic_Commission_Determination_Flow/301J000000001Tx exception by user/organization: 00DJ00000000YTl/{4} Source organization: 00DA0000000KZI8 (null)

interaction.dal.exception.DALExecutionFault: ; nested exception is:

                common.exception.ApiQueryException:

Account.Annual_RR__c FROM Account WHERE (Account.Id = '{!Commission__c.AccountId__c}')

                                         ^ ERROR at Row:1:Column:89 invalid ID field: {!Commission__c.AccountId__c} (There was a problem executing your command.) > RETRIEVE

 

caused by element : Data lookup.Lookup_Account

 

caused by: interaction.dal.exception.DALExecutionFault: ; nested exception is:

                common.exception.ApiQueryException:

Account.Annual_RR__c FROM Account WHERE (Account.Id = '{!Commission__c.AccountId__c}')

                                         ^ ERROR at Row:1:Column:89 invalid ID field: {!Commission__c.AccountId__c} (There was a problem executing your command.) > RETRIEVE

 

Salesforce Error ID: 580775287-15539 (1733087783)

 

What does this error message mean? How can I get more information on Salesforce errors and how to trouble shoot on this matter?

I understand this process is very complex but it relates back to one fundamental question: How do I get the flow to realize that it needs to pull information from the account that had the review date 14 days away in my apex scheduler?