Linking Two Templates Together with Custom Record Types

It seems that I have a decent sized Logic error in my application. With many stated variables to be operated against by a Controller with a Choice, they were assigned no values. So @SteveSeow suggested a way to address this, and I have been working through it but have had some weirdness arise.

Fixed: If I do not match the exact Number of Parties in the final Controller/Choice section with the Number of Parties in the next, linking Templates, it fails.

I now also see that if I introduce a custom data record in the first contract like:

data QueryDetails = QueryDetails
    currentPatient : Bool
    covid19Related : Bool
    queryName : Party                     
    queryMessage : Text
    queryDate : Date
  deriving (Eq, Show)

Fixed, well actually removed the Data Record calls: then assign that QueryDetails as a Party in the next Template, it causes that Number of Parties imbalance issue.

Also, incorrect Templates code removed.

So two questions:

  • Why am I getting Party numbering conflicts?
  • Why is the use of custom data records in a Template causing issues in the next Template?

I read through Workflow factoring and thought it was correct.

Update: The templates now seem to talk to each other correctly, although on execution of the CommenceConsult in the PrescribingPhysician.daml file, I am getting authorization errors:

Last Build Execution: Navigator.log

5:07:03.141 [] INFO c.d.n.s.platform.PlatformSubscriber - Command ‘2349414276b63aae’ completed with status ‘CommandStatusError(INVALID_ARGUMENT,Invalid argument: Command interpretation error in LF-DAMLe: Interpretation error: Error: node NodeId(0) (5b500d07f51bfc12c501a88e720e9a4fd34b1aff918a8faa37a27c47bafb84e1:PrescribingPhysician:CommenceConsult) requires authorizers Doctor,Medcentre,Patient, but only Doctor were given. Details: Last location: [DA.Internal.Prelude:378], partial transaction: root node NodeId(0): NodeCreate(ContractId(00fb2177dc86ea67ea125c91abbd0dd2a7019db81608bdd47801cec60fb39dffab),5b500d07f51bfc12c501a88e720e9a4fd34b1aff918a8faa37a27c47bafb84e1:PrescribingPhysician:CommenceConsult,ValueRecord(None,ImmArray((None,ValueParty(Medcentre)),(None,ValueParty(Doctor)),(None,ValueParty(Patient)),(None,ValueRecord(None,ImmArray((None,ValueBool(true)),(None,ValueBool(false)),(None,ValueParty(Johnny Boy)),(None,ValueInt64(3)),(None,ValueDate(2021-10-27)),(None,ValueText(Needs new Right Thumb)),(None,ValueBool(true)),(None,ValueText(Needs walking stick))))))),Simple line of placeholder textSimple line of placeholder text,TreeSet(Doctor, Medcentre, Patient),TreeSet(Doctor, Medcentre, Patient),None,V14).)’. akkaAddress=akka://da-ui-backend,, akkaSource=akka://da-ui-backend/user/$a/party-Doctor, sourceActorSystem=da-ui-backend, akkaTimestamp=02:07:03.141UTC

Executing the following Templates, gives me the same result:

  • template CommenceConsult
  • template ContinueConsult
  • template CompleteConsult

PrescribingPhysician:CommenceConsult) requires authorizers Doctor,Medcentre,Patient, but only Doctor were given.

Current CommenceConsult template
type CommenceConsultId = ContractId CommenceConsult -- Test, fail
template CommenceConsult
    commenceMedcen : Party                            -- Medcentre OBS?
    commenceDoctor : Party                            -- Doctor SIG
    commencePatient : Party                           -- Patient SIG?
    -- commenceDetails : DetailsCommenceConsult          -- Data Record
    commenceDetails : Text                            -- As Test
      "Simple line of placeholder text"
      <> "Simple line of placeholder text"
    signatory commenceMedcen, commenceDoctor, commencePatient

    controller commenceDoctor can
      CommenceConsult_Start : ContractId CommenceConsult -- Doctor; start
          create CommenceConsult
      CommenceConsult_Cancel : () do return () -- Doctor; cancel
    controller commenceMedcen can
      CommenceConsult_Stop : () do return () -- Medcen; stop

    controller commencePatient can
      CommenceConsult_Terminate : () do return () -- Patient; terminate 8-)

    controller commenceMedcen can

      ContinueConsult_Cease : () do return () -- Doctor; cease
      ContinueConsult_Action : ContractId ContinueConsult -- Doctor; action
          create ContinueConsult
              continueDoctor = commenceMedcen,
                continueMedcen = commenceMedcen,
                continuePatient = commencePatient

I have been over these templates a few times, according to daml.yaml, we are at version: 0.3.0 … well if nothing else, at least I am persistent :grinning:

1 Like

I don’t believe you can create composite and custom data type and set them as the values for a create argument that is expecting a Party. Let me and/or others confirm that.


Ah, well that might would explain it then, I’ll wait for an answer.

Update: After much reading, it seems that this is not doable directly. So, until I can work that out, the easy solution is to not use a Data Record to import Data from another Template. Although this issue was not actually causing the prime execution error … at least I have cleared that point up :thinking:

1 Like

Hi @quidagis,

If this is still an issue, would you mind sharing a (small) repro? Preferably in the form of a single module file that includes both your template definitions and a failing test.

As things stand, it’s really hard for me to figure out what you were trying to achieve, what you were actually doing, and what the problem you encountered was. But based on the title, I’d say it should definitely be possible to use a custom record type to transmit data from one contract to another.

PS: Updating the opening message in-line with new information as you seem to have done here (I haven’t seen previous versions) makes it a bit hard to follow what’s going on; adding new information in new messages usually makes it easier to follow for other people, especially if they come to the thread a bit later.


Hi @Gary_Verhaegen Thank you for that reply. I am still wanting to address this but am heartened that it is likely possible. As per your request, I will put something together this week, with one of the specific examples that failed.

Re the updating messages, fair point.

1 Like