# Multiple party agreement

**URL:** <https://forum.canton.network/t/multiple-party-agreement/2505>\
**Category:** App Development\
**Created:** [April 22, 2021, 11:55am UTC](https://forum.canton.network/t/multiple-party-agreement/2505 "2021-04-22T11:55:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![krmmalik](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/krmmalik/32/1410_2.png) [@krmmalik](https://forum.canton.network/u/krmmalik)\
**Post date:** [April 22, 2021, 11:55am UTC](https://forum.canton.network/t/multiple-party-agreement/2505/1 "2021-04-22T11:55:29Z")

</div>

I’ve been following the documentation on how to setup a [Multiple Party Agreement](https://docs.daml.com/daml/patterns/multiparty-agreement.html). (Great improvement to the documentation by the way. This was much needed)

My issue is that in the documentation example the `observers` are a party in the final contract to be created. However, in the multiple party agreement that I am creating, the observers are in a different contract called `Guild`.

So I included `guild` as

`guild: Guild` in my `pending contract` so that I could use the `members` party as observers. However, in setting this up, I am getting an error which I think is because I have included this incorrectly(?)

Could someone please give me some guidance?

Also, in the documentation example, the code used for sorting a list is just `sort` but I actually had to use `DA.List.Sort` ? Is that because of some change to the SDK?

Here is the error message

```haskell
/Users/khurammalik/DevTree/Qirad Agent Network/app/daml/Qirad.daml:126:19: error:
    • No instance for (DA.Internal.Record.HasField
                         "member" Guild [Party])
        arising from a use of ‘DA.Internal.Record.getField’
    • In the first argument of ‘DA.List.sort’, namely
        ‘(DA.Internal.Record.getField @"member" guild)’
      In the second argument of ‘(==)’, namely
        ‘DA.List.sort (DA.Internal.Record.getField @"member" guild)’
      In the first argument of ‘assert’, namely
        ‘(DA.List.sort approvingmember
            == DA.List.sort (DA.Internal.Record.getField @"member" guild))’

```

Here is my `Guild` , `proposal` and `ProposalGuildApproval’ code for reference.

```haskell
template Guild with
    guildName: Text
    creator: Party
    members: [Party]
  where
    signatory creator, members
    ensure length members >= 4 && DA.List.unique members

```

```haskell
template Proposal with
    issuer: Party
    investor: Party
    guild: Guild
    projectdescription: Text
    unitsrequired: Int
    marketingcost: Int
    distributioncost: Int
    additionalcost: Int
    proposalId: Text -- Key
    item: Item

  where
    signatory issuer, guild.members
    observer investor

```

```haskell
template ProposalGuildApproval with
    signedproposal: Proposal
    guild: Guild
    approvingmember: [Party]

  where
     signatory approvingmember
     observer guild.members

     ensure 
      DA.List.unique approvingmember
-- The parties who need to approve is the guild.members with approvingmember filtered out     
     let toApprove = filter (`notElem` approvingmember) guild.members

     preconsuming choice Approve : ContractId ProposalGuildApproval with
        approver : Party
      controller approver
        do
          -- Check the approver is in the toApprove list, and if they are, approve the ProposalGuildApproval contract
          assert (approver `elem` toApprove)
          create this with approvingmember = approver :: approvingmember

     preconsuming choice FinaliseApproval : ContractId Proposal with
        approver : Party
      controller approver
        do
          -- Check that all the required signatories have signed Pending
          assert (DA.List.sort approvingmember == DA.List.sort guild.member)
          create signedproposal

```

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [April 22, 2021, 12:05pm UTC](https://forum.canton.network/t/multiple-party-agreement/2505/2 "2021-04-22T12:05:44Z")

</div>

The error is in this line

```haskell
          assert (DA.List.sort approvingmember == DA.List.sort guild.member)

```

There is a typo in the field name: `member` instead of `members`. So try

```haskell
          assert (DA.List.sort approvingmember == DA.List.sort guild.members)

```

---

<div class="post-metadata">

**Author:** ![krmmalik](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/krmmalik/32/1410_2.png) [@krmmalik](https://forum.canton.network/u/krmmalik)\
**Post date:** [April 22, 2021, 1:32pm UTC](https://forum.canton.network/t/multiple-party-agreement/2505/3 "2021-04-22T13:32:28Z")

</div>

Gah! Thank you – so sorry for wasting your time!

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [April 22, 2021, 2:28pm UTC](https://forum.canton.network/t/multiple-party-agreement/2505/4 "2021-04-22T14:28:19Z")

</div>

Nothing to be sorry for, we’ve all been in the situation where we’ve stared at our code very confused until someone else pointed out the typo 🙂

---

<div class="post-metadata">

**Author:** ![krmmalik](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/krmmalik/32/1410_2.png) [@krmmalik](https://forum.canton.network/u/krmmalik)\
**Post date:** [April 22, 2021, 4:54pm UTC](https://forum.canton.network/t/multiple-party-agreement/2505/5 "2021-04-22T16:54:13Z")

</div>

Thanks again 🙂
