# Pulling out data from multiple contract

**URL:** <https://forum.canton.network/t/pulling-out-data-from-multiple-contract/2715>\
**Category:** App Development\
**Created:** [June 16, 2021, 2:06pm UTC](https://forum.canton.network/t/pulling-out-data-from-multiple-contract/2715 "2021-06-16T14:06:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hem-M](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/hem-m/32/2044_2.png) [@Hem-M](https://forum.canton.network/u/Hem-M)\
**Post date:** [June 16, 2021, 2:06pm UTC](https://forum.canton.network/t/pulling-out-data-from-multiple-contract/2715/1 "2021-06-16T14:06:54Z")

</div>

Hey,

I am trying to get data from the previously created multiple contracts within a template and combine partial dataset from each contract to make one final dataset. How can i achieve this in daml?

> – contract already created, in ledger  
> @ContractA2E  
> @ContractF2J  
> @ContractK2O
> 
> template CombineDataSet  
> …  
> do  
> cID1 ← @ContractA2E  
> cID2 ← @ContractF2J  
> cID3 ← @ContractK2O  
> and pull A,B from @ContractA2E; G,H from @ContractF2J; M,N,O from @ContractK2O - concat and store it in finalDataSet

Does daml samples have any such template snippet/use case reference to achieve this?

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [June 16, 2021, 4:53pm UTC](https://forum.canton.network/t/pulling-out-data-from-multiple-contract/2715/2 "2021-06-16T16:53:21Z")

</div>

You can lookup a contract on the ledger if you have [its contract ID](https://docs.daml.com/1.13.1/daml/reference/structure.html#choice-body-structure), or the [contract has a key](https://docs.daml.com/1.13.1/daml/reference/contract-keys.html) and you have that key, _and_ you are a stakeholder in the contract.

However, most workflows that build up a final contract like your `CombineDataSet` are _linear_ and _cumulative_, meaning they carry along the data from each preceding step, and each template has a choice that accepts additional data and takes you to the next step. [The new Daml training videos feature several examples of this.](https://discuss.daml.com/t/sneak-peek-of-new-daml-training-videos-for-daml-forum-members/2600)

If that does not fit your use case, contract IDs may be passed as choice arguments; this is the easiest way for you to get at the contracts you want to combine, but it is worth asking yourself: what do you want to happen to the prior contracts then?
