CMF Initializing a sub case in the parent case flow
Question
Application Type
Reactive

Hello All,

I am working on a CMF project that needs using the Subcase  https://success.outsystems.com/Documentation/Case_Management/Subcase#create-subcase

It is instructed in the documentation that after creating a subcase we can trigger a subcase in the parent flow instance by calling the <business-entity-name>_Create in an automatic activity. This method is built previously which does 2 things 1) initializing the case using the Case_Initialize in the CaseServices_API and 2) creating a record in the business entity of the case by taking the Source as a parameter.

In a normal situtaion when the user fills the Case form the <business-entity-name>_Create is called and the form inputs sent as a parameter to the method to initialize the case and add a record in the business entity. What confusing me is how can we call this method <business-entity-name>_Create in the parent flow while we still don't have the input Sorce for the subcase to send as the parameter. It makes sence to initialize the subcase here but not creating the business entity itself while we still don't have the data. 

let's assume we will only initialize the subcase here without adding a record and we will add the business entity record once the user fills the form of the subcase and submit it, how can we get the subcase Id that should be fetched from Case_Initialize.CaseId. 

Appreciate any help.


Solution

Sorry. That part was missing. So you are combining both projects into a single one. Is was thinking that both workflows stay separate as they are, thats why considered them to be separate.

In that case you definitely want to go for a parent / sub flow.

The parent flow for your project cases is created whenever someone fills in a form and a business entity record is created.

Then (i think) you have some portal where your users can see all open projects. They then browse to a single project and there would be a button "Add Change Request". That triggers a form where they fill in all the request details and hit submit. A server action then initializes a Case (Case_Initialise) with the Id (CaseId) of the Project Request and creates the Subflow Business Entity Data with that key. Actually no need to initialise the sub flow from the parent flow.

Hi,

For subcases there is a chance that you just want to initiate a sub flow without having any sub flow case data beforehand. Typically, those subcases start with a human activity to initially gather that data. In one of my projects i have Subcases which do not have an own Subcase Business Entity but modify data of the parents' case business entity.

You would initialize that sub flow either within your flow of the parent case or from outside of a case flow if you can query the parent case id.

The steps would be

  • Create a process for every sub flow with input parameter CaseId
  • Anywhere Initialise a new Case (Case_Initialise) with the parent case id
  • Use the manual Launch<FlowName>Process Action of your sub flow.

Best

Stefan



Thank you very much Stefan for your response. I am very glad that you are dealing with subcases because I need some more clarification and I hope you can help me. In my project, I have a "Parent Case" which is a Project Request coming from our Business department, the project request may contain multiple change requests which are the "Subcases". The Project Request cannot close until all its change requests closed. The change request has its own filds that the user needs to fill. 

Both the Project Request "parent" and the Change request "subcase" are CMF projects generated by workflow builder and I did my customization on top of them. My issue now is linking these two projects. Outsystems documentation suggested initializing the Subcase in the parent flow which makes sense but how can I create the subcase record while I  still don't have the data. 



I see. Unfortunately, i haven't worked with Workflow Builder. It sounds like you have two completely separated workflows then and not a real parent / sub case situation. Right? I mean that your change request cases where not initialised with a ParentId? But you need to have some sort of identifier which links a change request to a project. Maybe a project number? Its hard to tell anything without seeing it, but basically the thing you want to achieve is, that whenever someone clicks the Close Button on a Project Request you want to check if there are open change requests? I could think of one way to get that without having the "real" case identifiers.

in your change request Workflow project select the workflow for your case and set the Expose Process entity to true. In the Data Tab set the exposed Process to Public = True.

in your project request project create a reference to Process and ProcessStatus entities from System.

Wherever you want to check if someone can close a project request query the change request business entity for the project number to get a list of CaseIds

Query your Change Request Process Entity joined with Process and Process Status with an IN filter (custom sql) to the filteres CaseIds and ProcessStatus is Active.

If the result List is not empty that means you still have running change requests. 

Please note that i havent tried that myself.


Stefan 

Thank you Stafen for your detailed solution. Your understanding is right regarding my case, Yes, I have two completely separated workflows and I need to link them. The steps for creating a subcase in Outsystems documentation are the same exactly as creating a case. all these steps are already done by the workflow builder and I already converted it as a CMF project and everything is fine. The only things that differ in the subcase are these two steps mentioned in the document which I already added.

  1. After completing Step 5., in the <business-entity-name>_Create action, add an input parameter named ParentCaseId and with Case Identifier data type.

  2. Select the Case_Initialize action, and set the ParentCaseId as TextToIdentifier(ParentCaseId).

I think this made my case a real parent/sub-case situation. I don't know why you considered them as not, is there anything in the parent/sub-case situation that is not applied in my projects?

What you have explained regarding the case of closing the Project request will be really helpful, I am very interested to try implementing it. 

But, I still have some confusion regarding where to initialize the Subcase. I think initializing it in the parent flow is reasonable because we have to send the parent ID so we can link the two cases. But, I cannot create the business record without having the data. This part is not clear in the documentation and I don't know how did you handle it in your project.

I am really appreciating your responses and explanation. Thank you forever dear. 

Solution

Sorry. That part was missing. So you are combining both projects into a single one. Is was thinking that both workflows stay separate as they are, thats why considered them to be separate.

In that case you definitely want to go for a parent / sub flow.

The parent flow for your project cases is created whenever someone fills in a form and a business entity record is created.

Then (i think) you have some portal where your users can see all open projects. They then browse to a single project and there would be a button "Add Change Request". That triggers a form where they fill in all the request details and hit submit. A server action then initializes a Case (Case_Initialise) with the Id (CaseId) of the Project Request and creates the Subflow Business Entity Data with that key. Actually no need to initialise the sub flow from the parent flow.

Thank you very much Stefan, your suggestions helped me a lot at least I now know the approach that I should follow, remaining is the implementation.

Just a summary for our discussion:

- Parent Id should be added as input parameter in <business-entity-name>_Create action a named with Case Identifier data type which should be assigned in the Case_Initialize action.

- from the parent UI we can navigate to the Change Request form and at the same time trigger calling the Case_Initialize with sending the Parent Id parameter. 

- Before closing the parent Id, we have to get a list of CaseIds related to that parent and then check if any of them is not closed. 

Thank you again, our finding is great. I may refer to you if I faced other queries related to subcases. 

Yes. Having now a real parent / Sub relation you can use Case_GetAllSubcases from CaseServices_API to find out if there are any non-closed subflows.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.