I made a large change to my Hackathon app and had to expand the Communications functions from a simple Message to 4 x Templates with 2 choices for the User.
- Main template: Contact
- Secondary template with 2 Non-consuming Choices: Message
- Tertiary template #1: ShortMessage
- Tertiary template #2: LongMessage
I thought it would be helpful to change every sender, receiver, notes to reflect each Template. For the Contact Template, that would be contactSender contactReceiver, contactNotes.
However this seemed to cause conflict when referring to the Parties from one Template in the next template, in the previous template. So, I changed them all back to sender, receiver, notes and predictably are getting references to Ambiguous occurrence ‘sender’
Current conflicting version
{--
import Daml.Script
import DA.Time()
import DA.Date (Month(Apr), date)
--}
{--
| Contact application, might split out
| into it's own module, called Contact.daml
| 4 parts:
|
| Contact; Message; ShortMessage; LongMessage
--}
-- Contact Data Type & Template
--
type ContactId = ContractId Contact
template Contact
with
contactSender : Party
contactReceiver : Party
contactContent : Text
where
signatory contactSender
nonconsuming choice SendMessage : ContractId Message
with
userName : Party
content : Text
controller contactSender
do create Message with
messageSender = userName
messageReceiver = contactReceiver
messageContent = content
-- Message Data Type & Template
--
type MessageId = ContractId Message
template Message
with
messageSender : Party
messageReceiver : Party
messageContent : Text
where
signatory messageSender
observer messageReceiver
nonconsuming choice SendShort : ShortMessageId
controller messageReceiver
do shortContent
create ShortMessage with
shortSender
shortReceiver
shortContent
nonconsuming choice SendLong : LongMessageId
controller messageReceiver
do longContent
create LongMessage with
longSender
longReceiver
longContent
-- ShortMessage Data Type & Template
--
type ShortMessageId = ContractId ShortMessage
template ShortMessage
with
shortSender : Party
shortReceiver : Party
shortContent : Text
where
signatory shortSender, shortReceiver
-- Data Record for LongMessage
--
data LongMessageForm = LongMessageForm -- Detailed contact
with
covid19Vaccinated : Bool -- Currently COVID19 vaccine
patientName : Text -- First Last
patientNew : Bool -- New registration
patientCode : Int -- Next sequential number
patientGender : Text -- Male, Female, Other
patientType : Int -- NZ_Citizen, NZ_Resident, Other
dateOfContact : Date -- Date of consultation
extratNotes : Text -- Additional details, concise
deriving (Eq, Show)
-- LongMessage Data Type & Template
--
type LongMessageId = ContractId LongMessage
template LongMessage
with
longSender : Party
longReceiver : Party
longContent : LongMessageForm
where
signatory longSender, longReceiver
I was able to get the errors down to 1 instance of sender but I think I have a Logic/reference issue.
