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
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?
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
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
.
1 Like