There are 2 different ways to invoke a BPD as an activity within another BPD in IBM BPM. These are "SubProcess" and "Linked Process". The important question here is which of the 2 you used to implement this. You stated "Sub Process". The primary difference in these 2 are in how they are created.
"SubProcesses" are not reusable as they are created in the context of the activity in the Parent BPD. They also do not have their own variables, but rather inherit the context of the BPD within which they were created. Both of these factors are why are some of the reasons why I don't like using them, as they can lead to variable sprawl and prevent proper code reuse. If you really are using a SubProcess, then there is no "Name" associated with the SubProcess, but rather just an internal GUID used by the engine for tracking the items. In this case there really is no "BPD Name" for you to use, just the Activity name on the Top level BPD.
"Linked Processes" actually exist in the Library as their own entities. These can be reused, and have their own execution context (variables etc.). They can be invoked as Activities in another BPD. If this is what you have done there is a chance you can get the data you want, however it will likely require several calls to the ReST API. I created a quick solution consisting of a BPD called "Test Execution Tree" containing one activity invoking a linked BPD called "Simple Child Process" in that process I had 1 human activity assigned to me.
I created an instance of this BPD and then invoked -
https://<myserver>:<my port>/rest/bpm/wle/v1/process/3903?parts=executionTree%7Crelationships
The response was -
{
"status": "200",
"data": {
"description": null,
"richDescription": null,
"caseFolderServerName": null,
"processAppName": null,
"processAppAcronym": null,
"processAppID": null,
"snapshotName": null,
"snapshotID": null,
"snapshotTip": false,
"startingDocumentServerName": null,
"comments": null,
"tasks": null,
"documents": null,
"actionDetails": null,
"relationship": [
],
"executionTree": {
"executionStatus": "1",
"root": {
"name": "Test Execution Tree",
"nodeId": "1",
"createdTaskIDs": null,
"variables": {
},
"children": [
{
"name": "Call Linked BPD",
"nodeId": "5",
"flowObjectId": "c8e578da-b2dd-4ee3-85d8-24ccdb140d04",
"taskType": "5",
"tokenId": "4",
"createdTaskIDs": null,
"variables": {
},
"children": [
{
"name": "Process \"Simple Child Process\"",
"nodeId": "6",
"processId": "25.6848e351-1557-4374-8afb-389641578b31",
"branchId": "2063.17a1692b-bc3a-4a2f-99c2-155e76264961",
"createdTaskIDs": null,
"children": [
{
"name": "Inline User Task",
"nodeId": "10",
"flowObjectId": "13621c37-7ab0-4650-90b8-40beb58bc134",
"taskType": "1",
"tokenId": "9",
"createdTaskIDs": [
"5053"
],
"variables": {
},
"children": null
}
],
"DataModel": {
"properties": {
},
"inputs": {
},
"outputs": {
},
"validation": {
}
}
}
]
}
]
}
},
"actions": null
}
}
In the above you can see that the current task is ID 5053, and the parent to that task is a BPD with the GUID of 25.6848e351-1557-4374-8afb-389641578b31 and the name "Process "Simple Child Process"". So if the user task was the system task you are invoking it could make this call, find it's own entry in the JSON, and navigate up to the parent.
Now, having said all of this, I would question the utility as my users rarely ever know about the Linked / Sub Process and only ever really know the parent the owns it, so unless the e-mail is specifically intended for a support team I would think the correct "noun" to use would be either the overarching process that is running, or the activity in that BPD that invoked the sub process.
Hope this helps.
------------------------------
Andrew Paier
------------------------------
Original Message:
Sent: Tue October 15, 2019 08:30 AM
From: Grant Pozzana
Subject: Unable to get the name of the BPD that called a service
Hi,I'm currently trying to get the name of the parent BPD to a system task.
We have 'BPD A' (main process), that drops in to 'BPD B' (sub process) and within the sub-process we have a step called, let's say "Send Message" which implements a system task service. At a point in the service I want to get the name of the BPD ('BPD B') that invoked the service.
Basically the called service is going to be a re-usable Toolkit component and could be called from a number of different sub processes in various process apps. We want to generically get the name of the parent BPD - essentially "I was called by...X"
I have tried various combinations within the tw.system namespace (currentTask / currentProcess / currentProcessInstance) and all I can seem to retrieve is either the name of the main BPD ('BPD A' - tw.currentProcess.name) or the actual step name as the service box is named within the sub-process BPD ("Send Message" - tw.system.currentTask.processInstanceStep.name).
Essentially I would like to get something like 'currentTask.parentBPD.name' but I'm beginning to think this isn't even possible. I seem to only be able to get the step name or the instance name, but not the current sub-process name (the middle step).
Does anyone know of a way to get this information at run-time? I don't mind if I need to get some GUID and call an API to retrieve the details of it, or if I'm just completely missing where this name is stored...
Cheers!
------------------------------
Grant
------------------------------