You need to sign in to do that
Don't have an account?
venkatasubhashk
How to update a field in Apex from a Relationship Query
I have a Query like this ...
for(opportunity opp1 :opp){
ProcessInstance p= [SELECT Id, (SELECT Id, StepStatus,Comments FROM Steps)FROM ProcessInstance WHERE Status='Approved' and TargetObjectId=:opp1.id limit 1];
opp1.comments = p.comments;
//This is not working
i want to get the comments from the Query to custom field
}
any ideas please!!
The ProcessInstance object doesn't have a field called 'comments', so you won't be able to assign that value to the opp1.comments field.
The Steps within the process do have comments, but there may be many Steps associated with a ProcessInstance.
Thus you probably want to produce a concatenated set of comments for the opportunity, something like: