You need to sign in to do that
Don't have an account?
shakila G
How to fetch process instance step related records with custom object subquery
HI All,
Am trying to fetch Custom object related Approval process records information from processinstance step using soql workbecn.
Select Account__r.Name,Team_Member__r.Name ,Team_Member__r.ISActive,Team_Member_Email__c,Team_Role__c, Status__c,RHMS_Approval_Status__c, Approval_Status__c ,(SELECT ProcessInstance.TargetObjectId ,Comments FROM ProcessInstanceStep)from Account_Team__C
where ID='a4Qc0000000kBDt'
Am getting following error..
Didn't understand relationship 'ProcessInstanceStep' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Kindly let me know ..How to fetch alll those records using workbench..
Am trying to fetch Custom object related Approval process records information from processinstance step using soql workbecn.
Select Account__r.Name,Team_Member__r.Name ,Team_Member__r.ISActive,Team_Member_Email__c,Team_Role__c, Status__c,RHMS_Approval_Status__c, Approval_Status__c ,(SELECT ProcessInstance.TargetObjectId ,Comments FROM ProcessInstanceStep)from Account_Team__C
where ID='a4Qc0000000kBDt'
Am getting following error..
Didn't understand relationship 'ProcessInstanceStep' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
Kindly let me know ..How to fetch alll those records using workbench..
you cannot fetch approval records by applying direct soql on custom object. There is different set of objects like process instance, process defination, processinstancestep, processDefination and others which strores approval related data like you can check following link.
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_processinstance.htm
You can explore these objects on workbench in SOQL query section
Thanks for the update.
I tried that option ..
Select Account__r.Name,Team_Member__r.Name ,Team_Member__r.ISActive,Team_Member_Email__c,Team_Role__c, Status__c,RHMS_Approval_Status__c, Approval_Status__c ,(SELECT Id, (SELECT Id, StepStatus, Comments FROM Steps)
FROM ProcessInstances)from Account_Team__C
where ID='a4Qc0000000kBDt'
IF trying to fetch that way... am getting follwoing error..
MALFORMED_QUERY: SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object.
So only itried to fetch directly from process instanse step....
Kindly provide some solution to fetch all the information
this is rougly you can get information
ProcessInstance p=[SELECT id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectid FROM ProcessInstance where TargetObjectid='a4Qc0000000kBDt']
Account_Team__C at=new Account_Team__C();
at=p.TargetObjectid;//Now at have custom object id. using that you can retrieve that record related information
system.debug(at.RHMS_Approval_Status__c);
system.debug(at.Team_Role__c);
system.debug(at.Team_Member_Email__c);
Just need to write a soql query to generate all those information with 1 set of query...
Only soql query...My third party application required only kind of soql query not Apex class..
Select id,name from Account where id in (select TargetObjectid from ProcessInstance where TargetObjectid='a4Qc0000000kBDt')