Skip to content
Discussions/App Development/Canton date format issuesForum ↗

Canton date format issues

App Development7 posts195 viewsLast activity Jun 2023
JO
Joy_KOP
Jun 2023

I am getting error while setting date value in Daml contract from canton script.
RROR c.d.c.c.EnterpriseConsoleEnvironment - Request failed for participant1.
GrpcClientError: INVALID_ARGUMENT/COMMAND_PREPROCESSING_FAILED(8,71e073be): mismatching type: Date and value: ValueText(2023-11-09)
val job1 = Map(“dateOfJob” → “2023-11-09”, “jobEnumId” → 1, “artifactId” → List(1))

ST
stefanobaghino-da
Jun 2023

How are you setting it? It looks like you are passing a string rather than a date.

JO
Joy_K
Jun 2023

for date type also it is not working val job1 = Map(“dateOfJob” → LocalDate.of(2022, 7, 22), “jobEnumId” → 1, “artifactId” → List(1)).
I have tried multiple thing java function for date is not working while setting the value in daml contracts from canton

ST
stefanobaghino-da
Jun 2023

I’m not 100% sure that LocalDate is the type you need. Can you please share how you’re setting it? Without seeing your the part of the script that fails it’s difficult to tell what the error might be.

JO
Joy_K
Jun 2023

this is data from contracts :-1:
data Job = Job
with
dateOfJob : Date
jobEnumId : Int
artifactId : [Int]
deriving (Eq, Show)

What value i need to set from canton because nothing is working at all.
val badge1 = Map(“id” → “badge1”, “name” → “Badge 1”)
val certificate1 = Map(“id” → “certificate1”, “title” → “Certificate 1”)
val job1 = Map(“dateOfJob” → LocalDate.of(2022, 7, 22), “jobEnumId” → 1, “artifactId” → List(1))
val feedback1 = Map(“id” → “feedback1”, “rating” → 5, “summary” → “Great job!”)

val cont1 = Map(“pmcId” → 15, “role” → contributor, “name” → “APIN”, “grade” → “”, “actualProject” → “”, “billingType” → “”, “certificates” → List(certificate1), “wallet” → 1000.00, “badges” → List(badge1), “feedbacks” → List(feedback1), “jobs” → List(job1), “admin” → admin)

createContributorContractIfNotExists(cont1)

JO
Joy_K
Jun 2023

if val job1 = Map(“dateOfJob” → java.time.LocalDate.parse(“2023-01-12”), “jobEnumId” → 1, “artifactId” → List(1))
then
ERROR c.d.c.ConsoleInteractiveRunner - Running bootstrap script failed with an exception (value type not yet implemented: class java.time.LocalDate)!

dateOfJob -Date type in daml

ST
stefanobaghino-da
Jun 2023
Joy_K:

createContributorContractIfNotExists

What does this function do?

← Back to Discussions