New Error class java.lang.Double cannot be cast to class java. lang. String

2176
2
Jump to solution
10-01-2021 11:09 AM
ShariForbes
New Contributor III

Hello. A few days ago our calculation to prepopulate a field based on the default of another field and worked fine but now we get that java error that I don't fully comprehend. 

 

For ProjectNo X, fill in Project Address, like follows.

if(selected(${ProjectNo}, '1'), '783 Antoine Dr', if(selected(${ProjectNo}, '2'), '860 Acadia Dr’, if(selected(${ProjectNo}, '3'), '770 Andre Ct’, if(selected(${ProjectNo}, '4'), '860 Cambridge Dr’, if(selected(${ProjectNo}, '5'), '868 Cambridge Dr’, if(selected(${ProjectNo}, '6'), '812 Grand Teton Dr’, if(selected(${ProjectNo}, '7'), '929 Grand Teton Dr’, if(selected(${ProjectNo}, '8'), '3321 Nice Dr’, if(selected(${ProjectNo}, '9'), '784 Noel Trl’, if(selected(${ProjectNo}, '10'), '768 Pierre Ln’, if(selected(${ProjectNo}, '11'), '804 Rushmore Ln’, if(selected(${ProjectNo}, '12'), '753 Warwick Dr’, if(selected(${ProjectNo}, '13'), '3301 Thunderbird Ln’, ‘Please choose a project number’)))))))))))))

 

I've attached my .xls form too. Appreciate any advice. 

0 Kudos
1 Solution

Accepted Solutions
DeonLengton
Esri Contributor

Hi Shari

I found a few issues in your survey. Your if statement contains inconsistent single quotes - some of them seem to have been copied from Word so they have a different format. I usually copy those text blocks into Notepad to get rid of any special characters and then copy it from there into my Excel sheets.

DeonLengton_0-1633336062792.png

I do however suspect the biggest problem was that ProjectNo is defined as an integer and the selected() function compares it to a String value. I would change the bind::type for ProjectNo to string it should fix your survey:

DeonLengton_1-1633336148075.png

bind::type changes the way Survey123 looks at your field in survey calculations such as selected()

I have attached a working Excel design file for your survey.

Hope that helps.

 

View solution in original post

2 Replies
DeonLengton
Esri Contributor

Hi Shari

I found a few issues in your survey. Your if statement contains inconsistent single quotes - some of them seem to have been copied from Word so they have a different format. I usually copy those text blocks into Notepad to get rid of any special characters and then copy it from there into my Excel sheets.

DeonLengton_0-1633336062792.png

I do however suspect the biggest problem was that ProjectNo is defined as an integer and the selected() function compares it to a String value. I would change the bind::type for ProjectNo to string it should fix your survey:

DeonLengton_1-1633336148075.png

bind::type changes the way Survey123 looks at your field in survey calculations such as selected()

I have attached a working Excel design file for your survey.

Hope that helps.

 

ShariForbes
New Contributor III

Deon. Thank you for taking the time to look at my survey and sending me back an improved example. 

I appreciate the advice about copying into a text file and I try to do that, but that expression had been copied and pasted so many times I am not surprised something went out of whack. 

Thanks also for the tip about bind:type

Every time I do a project with Survey123 I learn something new.