Create a different case from a case registration form that is not a child case

Im hoping someone can help or give me an idea for a different line of attack.

Please see the picture below which kinda sums up the scenario I am trying to achieve.

Basically what I want to happen is that when a case(dispatch) is created at location1 by mobile worker 1, another case(receiving) is created for location2 with a copy of the same child cases and some of the dispatch case properties copied to the parent receiving case properties so that they are already completed when a followup form is opened for a receiving case. This is so that when mobile worker 2 who is assigned to location 2 logs in and opens up the case list for receiving they will see a new case there, with a lot of information already completed(filled out).

I have seen in another project the Advanced question option called Save to Case, where they use it to make updates to an existing case.
I have been trying to use that to create a receiving case when completing the dispatch case, but I cant seem to get it to work.

Any ideas or assistance would be greatly appreciated!


I am not entirely sure I understand you correctly but let me split what I understood into two parts
1- Create Case A for location 1, automatically create a Case B for location 2.
if Case A has child cases, you also want a copy of those child cases to be parented by Case B. this one is tricky.

the standard way of making more than one case with the same form makes one of those cases the parent. so, you would need to break that relationship. the only way to do that is to already have the case in context. it can be done for the Case B while creating it, you would just set a value to the owner_ID as you wish for it, and parent case id to be blank. HOWEVER, if you do create the duplicate of the child cases, they would be parented not by case B, but Case A. and since Case B cannot be referenced inside the form that creates Case A, you would need to interact with the cases AFTER they were created. which means a separate form interaction.
in case you did, it would be simply remapping the parent case id to be pointing to case B. but again, that's a separate case interaction that's pretty annoying cause it won't do much on screen - not a lot of interaction needed.

2- When the duplicate case is updated, you want that update to go back to the first case tree.
boy have you picked a tough one. since there is no parent child relationship between those cases, you need to explicitly refer to them using the save to case function. to do that, you would need the case ID's of those cases that you need to update, along with making a bunch of calls to grab the rest of those case details so as not to override any data that is already there. it's a pain to handle, because you would need to
A - Get the parent case id for whichever child case in steam A or B
B - write a query to get a list of case ID's that have that case as a parent (clone cousins)
C - find the right one of those cases to update
D - grab the rest of that cases's details
E - use save to case functionality

Easy? NO!

Did I understand you correctly?

Hi Calvin

You can certainly use 'save-to-case' to do this. That question type gives you complete control over the creation and update of cases including their relationships. This makes a very powerful, but also dangerous feature.

Can you say more about how you have this configured and what isn't working?

Hi @Mazz and @Simon_Kelly,

Thank you both for your responses.
@Mazz I think you pretty much have nailed down what I am trying to achieve, thank you for your detailed response! Its given me some ideas of how I am going handle this. Im busy working on a barebones proof of concept at the moment, which I will comeback and share about here when Im done, maybe it will help others in the future.

@Simon_Kelly I'm only now really becoming familiar with the 'save-to-case' feature. I have seen it used in the past on another project to update a case, but that's where it ended. I figured out where I was going wrong when trying to create a case. I was using a Hidden Value and setting the Calculate Condition to uuid(), then I was setting the Case ID of the save-to-case to this Hidden Value. The save-to-case was throwing an error because of this when trying to submit the form. Eventually figured if I set the Case ID to the function uuid() it then created a case. The downside of this is I dont know what the case id of the new case is. Is there a way to set the Case ID when creating a new case with something like a hidden value or does it only work with the function uuid()? Or maybe I can somehow pull the case id from the save-to-case question(I have tried, but havent been able to get that to work)?

So what I have resorted to is creating a hidden value on the form with the calculate condition set to concat("receiving-", uuid()) then assigning that hidden value to a case property called receiving_lookup_id under the 'properties to update' of the save-to-case. This way I can now track the receiving case so that when I create/update child dispatch commodities for the dispatch case, I can then create/update child receiving commodities for the receiving case. I will probably have to do similar with the child cases. If that makes sense.

Here is a sort of diagram of what I am thinking (Pictures help haha)

Hope that all makes sense, will come back and let you know how it goes once I complete a POC.
Thanks guys.

Hi Calvin

You can use a hidden value to store the case ID but instead of setting the 'Calculate Condition' of the hidden value you need to set its 'Default Value' field to uuid(). The reason for this is that the save-to-case case ID value is 'bound' at the start of the form but calculate conditions are only evaluated after that. This explains why the case ID was blank before. Default Value expressions are evaluated on form load which means that it will have a value set by the time the case ID is bound.



I didn't actually know you could set your own case id using the uuid function!

this changes everything :see_no_evil: :hear_no_evil: :speak_no_evil:

1 Like

Thank you @Simon_Kelly this is exactly what I was hoping for! Really appreciate the explanation as well. That makes sense.