Conflicting definitions for ‘alias’

I have uploaded my latest file which solved the previous errors but created others …

Registration.daml (2.9 KB)

a new template "AliasCitizen" was added with the goal for allowing a citizen alias so this ‘alias’ can be referenced in project dable instead of the long id.

1 Like

The error you’re seeing at line 58 is Conflicting definitions for ‘alias’. That’s due to the parameters for that choice having the same name as the fields in the template (citizen and alias). If you want that choice to only change the alias, I’d rewrite it as:

    controller citizen can
      nonconsuming SetAlias : ContractId AliasCitizen with
         newAlias : Text
       do
         create this with alias = newAlias

The syntax of create this with ... simply means: take a copy of the current contract and change the fields explicitly specified on the right hand side (alias in this case).

The next error I’m getting is around the observers on that template, which aren’t present anywhere:

observer healthclinic, statehealth, operator

You’ll either need to add those parties as fields on the template, or just remove the observer line if you don’t need the contract to be visible to them.

Finally, there are several issues in the last statement in your scenario:

  aliceupdate <- submit alice do
    exercise UpdateRegistration with 
      registrationCid = citizenkey ; registrationData = newCitizenDetails

First, you’re missing the contract id of the contract you want to exercise the UpdateRegistration choice on. I suppose that would be either aliceregistration or bobregistration and you’d put it right after the exercise keyword.

Then, the arguments to the UpdateRegistration choice are wrong. The only argument for that choice is called newCitizenDetails, so you’ll only need to pass in this parameter. The statement would then look like this:

aliceupdate <- submit alice do exercise aliceregistration UpdateRegistration with newCitizenDetails = newCitizenDetails

Since the variable you’re passing in named the same as the parameter of the choice, you can use the shorthand:

aliceupdate <- submit alice do exercise aliceregistration UpdateRegistration with newCitizenDetails

Or even:

aliceupdate <- submit alice do exercise aliceregistration UpdateRegistration with ..

The .. here means: look for variables that have the same name as my parameters and pass those in to the choice.

With these things fixed the scenario works for me. Hope this helps.

3 Likes

@georg

Excellent feedback !!! Appreciate the explanations and fixes

I think I am getting a hang of it now…

2 Likes