Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/How to write choice that fetch record against nameForum ↗

How to write choice that fetch record against name

App Development4 posts275 views1 likesLast activity Oct 2020
MU
Muhammad_MoizOP
Oct 2020

I want to write a choice that fetch data against name on this template

template Resident
    with
        name : Optional  Text 
        gender : Optional Text
        dateOfBirth : Optional Date
        race : Optional Text
        systemUser : Party
    where    
    signatory  systemUser
BE
bernhard
Oct 2020

Could you be a bit more specific? Are you looking for a function that extracts the Text from the Optional Text? Of so what happens if the Optional is None? Are you looking to fetch another contract based on the value of name? In that case, what does the other contract look like?

MU
Muhammad_Moiz
Oct 2020

I just want a function to search resident by name if that record is present it show me else it show nothing.
Are you looking to fetch another contract based on the value of name ?
No

BE
bernhard
Oct 2020

DAML’s only query functionality is Contract Keys, which do almost what you need, I think. If you had name : Text, not name : Optional Text, you could declare a contract key using name and then look up Resident contracts using that key. But because contract keys enforce uniqueness on the key, you wouldn’t be able to have more than one such contract with name = None.

← Back to Discussions