IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 1 reply
  • Latest Post - ‏2019-10-16T13:53:47Z by AndrewPaier
tw.local.Grant
tw.local.Grant
21 Posts

Pinned topic Can't get the name of the parent BPD the current service

‏2019-10-15T11:01:22Z | 8.5.7 baw bpm

Hello,

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 'Service B' 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.

 

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!

  • AndrewPaier
    AndrewPaier
    1203 Posts

    Re: Can't get the name of the parent BPD the current service

    ‏2019-10-16T13:53:47Z  

    I actually answered this question in the other forum you posted it in - https://community.ibm.com/community/user/automation/communities/community-home/digestviewer/viewthread?MessageKey=96c00020-a1f0-408d-9127-0859e0854c00&CommunityKey=810abde6-3916-441b-aac3-b9105bb37e3c&tab=digestviewer#bm96c00020-a1f0-408d-9127-0859e0854c00

    However I'll post the same answer here for completeness sake.

     

    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
    ------------------------------