Can we specified the authority in field's level?
Hi DAML’ers,
I’m currently trying to learn DAML by developing such a card activity management system. I have a template, let’s say Card which consists of cardType, cardStatus, ExpiredDate, and PINOffet. However, I need to restrict the PINOfset field, even signatory is not allowed to see it.
How to do that in DAML? is there any mechanism to restrict the authority in field’s level?
Your feedback very useful for me.
Thank you 
Hi @nr185,
if I understand you correctly you want to limit visibility of specific fields instead of having visibility be defined at the level of contracts.
Currently that is not possible. Either a party sees a contract and all fields in it or it doesn’t see the contract at all.
So if you want to limit visibility of specific fields, you need to split the contract into different ones with different fields and then have different visibility on those contracts.
Hi @cocreature …
Thank you for your feedback!
Yes, you are correct. That’s what I mean.
Hi DAML ers,
I am currently, trying to create a daml program about card activity management. In short, this system is about linking card number with the account number, activate the card (update card status from not active to active), and once the activation is success, it will update count of the card stock in card Inventory, will become count -1.
Hence, I create 3 templates : CardInventory, Card, and Account.
Now I get an error as shown in this pic.
This is from the Card Template. I’m confused why this error happened.
Your feedback will be very helpful for me.
Thanks a lot.
Looks like you just have to assign values to the fields customerService, cardInv and branch when you create the card. Just like you did with cardNumber, cardStatus and lastUpdate. It would be helpful if you’d share the definition of the Card template.
Yes,
This is the complete version for the card template.
template CardInventory
with
branch : Text
count : Int
staff : Party
auditor : [Party]
customer : Party
where
signatory staff
observer auditor
template Card
with
cardNumber : Text
cardStatus : Text
lastUpdate : Date
customerService : Party
cardInv : CardInventory
branch : Text
where
signatory customerService, customer
observer cardInv.customerService, cardInv.auditor
preconsuming choice ActivationCard : ContractId Card
with
newCard : Text
controller customerService
do
cardContractId <- lookupByKey @Card(cardNumber, cardStatus)
now <- getTime
assertMsg "This card status must be Not Active (NA)" (cardStatus /= "NA")
assertMsg "Update card stock in branch" (branch /= cardInv.branch)
create Card with
cardNumber = newCard
cardStatus = "AA"
lastUpdate = now
Thank you for your help and sorry for the very basic question. I need to fully understand about this.
Hey @nr185 welcome to the forum!
If your intent with the ActivationCard choice is to archive the current contract and replace it with the activated version you can do create this with instead of create Card with. When you do this you only need to update the fields you want to and the rest will keep their previous values.
Also the choice is currently preconsuming and you might have to remove that.
Also some other notes:
- I noticed your
Cardtemplate has acustomersignatory but that’s not a field onCardperhaps you intendedcardInv.customer? -
assertMsg "This card status must be Not Active (NA)" (cardStatus /= "NA")from the error message this seems to suggest that you want to docardStatus == "NA"
Hi @anthony, thank you for your feedback. Very helpfull 
You shouldn’t have a let directly after a with. Try just deleting that line (between CardInventory with and branch).
Many thanks for your response!
By the way, how to assign “Date” type in DAML?
I try this dob = 09-12-2012 and it’s error.
Dates do not have a literal representation in Daml, so you have to “build” them by calling functions on other data types. Here’s a full, self-contained example:
module Main where
import Daml.Script
import DA.Date
test : Script ()
test = script do
let today = DA.Date.fromGregorian (2021, DA.Date.Aug, 4)
debug $ "Today is " <> show today
return ()
The debug call outputs:
Today is 2021-08-04
Ooh I see. Thank you for your help! 

