# Get property from union typed member in a test

**URL:** <https://forum.canton.network/t/get-property-from-union-typed-member-in-a-test/1092>\
**Category:** App Development\
**Tags:** daml\
**Created:** [August 25, 2020, 12:18pm UTC](https://forum.canton.network/t/get-property-from-union-typed-member-in-a-test/1092 "2020-08-25T12:18:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_m](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/alex_m/32/550_2.png) [@alex\_m](https://forum.canton.network/u/alex_m)\
**Post date:** [August 25, 2020, 12:18pm UTC](https://forum.canton.network/t/get-property-from-union-typed-member-in-a-test/1092/1 "2020-08-25T12:18:50Z")

</div>

I am trying to create a unit test where one of my templates has a member `details` that is typed as

```haskell
template Record
  with
    ...
    details : RecordDetails
    ...

data RecordDetails 
  = SaleRecord SaleRecordDetails
  | OfferRecord OfferRecordDetails
  ...

data SaleRecordDetails = SaleRecordDetails
  with
    ...
    price : Decimal

```

In my test case, I want to be able to do a check like:

```haskell
   ...
   pure (product.price == record.details.price)

```

I get the error:

> No instance for (DA.Internal.Record.HasField “price”…

How can I tell the scenario that the record should have `details` as `SaleRecordDetails`? I am receiving my `Record` object from a choice that creates the `Record` as a `SaleRecord`.

Thanks again for the help!

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [August 25, 2020, 12:27pm UTC](https://forum.canton.network/t/get-property-from-union-typed-member-in-a-test/1092/2 "2020-08-25T12:27:54Z")

</div>

When you define a new variant type, out of the box, the only way to distinguish between variants is pattern matching. So in your case, you may want to make up a function along the lines of:

```haskell
checkPrice: int -> RecordDetails -> Bool
checkPrice n r = case r of
  SaleRecord details -> n == details.price
  _ -> False

```

---

<div class="post-metadata">

**Author:** ![alex\_m](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/alex_m/32/550_2.png) [@alex\_m](https://forum.canton.network/u/alex_m)\
**Post date:** [August 25, 2020, 12:36pm UTC](https://forum.canton.network/t/get-property-from-union-typed-member-in-a-test/1092/3 "2020-08-25T12:36:46Z")

</div>

Great, thanks!
