Parse error in pattern: exercise Possibly caused by a missing 'do'?

Hi, EveryOne I want to save the current date and time. I do following but get this error I search on the network but can’t able to solve it

    template Attandance 
        with
            systemUser : Party
            associate : Optional Party
            punchInTime : Optional Time
            punchOutTime :Optional Time
        where 
            signatory systemUser
            nonconsuming choice PunchIn 
                : ContractId Attandance
                with
                    currentTime : Time
                controller associate 
                   do 
                    create this with punchInTime = Some currentTime 
            nonconsuming choice PunchOut 
                : ContractId Attandance
                with
                    currentTime : Time
                controller associate 
                   do 
                    create this with punchOutTime = Some currentTime

Here is my scenario of update punchIn but it show me error when i exercised PunchIn exercise
Parse error in pattern: exercise
Possibly caused by a missing ‘do’?

atid <- submit systemUser do
        create Attandance
            with
                systemUser
                associate  = None   
                punchInTime = None
                punchOutTime = None   
 submit associate do
        exercise asid PunchIn with
            currentTime <- getTime
    return()
1 Like

You’ll need to run getTime on a separate line. Something like:

submit associate do
  currentTime <- getTime
  exercise asid PunchIn with currentTime

I don’t think you can use <- syntax in a with block like that. I do think we need a better error message, but unfortunately I expect this is part of GHC and therefore we have limited ability to change it.

2 Likes

A post was merged into an existing topic: Error: Attempt to fetch or exercise a contract not visible to the committer