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
sdharsdhar 

Soql Query not returning the latest rejection comments when used in VF Email Template

I have a strange issue..

We are trying to capture the rejection comments as part of approval process and include it in the email notification sent to Opportunity owner. hence using a VF Email template(inturn uses VF component) to include the details of the rejection. Showing the latest rejection comments in the email.

 

Im using below query in the  and is not returning the latest comments. It returns the previous rejection comments.

 

Opportunity quote = [Select Id, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps where StepStatus = 'Rejected' order by SystemModstamp desc limit 1) from Opportunity where Id = :opptyLineID];
    for(ProcessInstancehistory ps:quote.ProcessSteps)
    {
        strOut=strOut+ps.Comments;
    }

 If I execute the same code in developer console I get the correct data.. not sure what is going wrong here..

any help is appreciated..