Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created March 1, 2016 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoshikawa1106/b6d6ef0d6abad9ac4b62 to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/b6d6ef0d6abad9ac4b62 to your computer and use it in GitHub Desktop.
承認履歴情報周りの取得方法サンプルクエリ
ProcessInstance p = [
SELECT
Id
,CompletedDate
,LastActorId
,ProcessDefinitionId
,Status
,TargetObjectId
,(SELECT Id,ActorId,Comments,IsPending,OriginalActorId,ProcessInstanceId,ProcessNodeId,StepStatus,TargetObjectId FROM StepsAndWorkitems)
FROM
ProcessInstance
LIMIT 1
];
// ProcessInstanceの確認
System.debug('-- ProcessInstance --');
System.debug(p);
// ProcessInstanceHistoryの確認
System.debug('-- ProcessInstanceHistory --');
for (ProcessInstanceHistory sw : p.StepsAndWorkitems) {
System.debug(sw);
}
// ProcessNodeId取得
Set<String> nodeIds = new Set<String>();
for (ProcessInstanceHistory sw : p.StepsAndWorkitems) {
nodeIds.add(sw.ProcessNodeId);
}
List<ProcessInstanceNode> processNodes = [
SELECT
Id
,CompletedDate
,LastActorId
,NodeStatus
,ProcessInstanceId
,ProcessNodeId
,ProcessNodeName
FROM
ProcessInstanceNode
WHERE
ProcessNodeId IN: nodeIds
];
System.debug('-- ProcessInstanceNode --');
System.debug(processNodes);
// 参考サイト
// https://developer.salesforce.com/docs/atlas.ja-jp.198.0.object_reference.meta/object_reference/sforce_api_objects_processinstance.htm?search_text=ProcessInstance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment