Hello,
I have created a survey in SURVEY123, and I get the following error: STRING OR BINARY DATA WOULD BE TRUNCATED. THE STATEMENT HAS BEEN TERMINATED. I have looked at the solutions that are uploaded to the forum and they have not worked, I have changed the length of the field, I have changed the type of this and I still get the same error.
my case is the following:
I have created a survey for vehicle monitoring and I have a field called initial kilometers.
I would like this field to be filled with the previous value that has been put, for this I have made a script in JavaScript (thanks Ismael Chivite for the help).
function getLastGeneratorReading(Parte_de_vehiculo,token){
var xmlhttp = new XMLHttpRequest();
var params = "/query?";
params = params + "where=Parte_de_vehiculo='" + Parte_de_vehiculo + "'&outFields=KmIni"
params = params + "&returnGeometry=false&orderByFields=OBJECTID DESC&resultRecordCount=1&f=json";
if (token ){
params = params + "&token=" + token ;
}
var url = featureLayer + params;
xmlhttp.open("GET",url,false);
xmlhttp.send();
if (xmlhttp.status!==200){
return (xmlhttp.status);
} else {
var responseJSON=JSON.parse(xmlhttp.responseText)
if (responseJSON.error){
return (JSON.stringify(responseJSON.error));
} else {
if (responseJSON.features[0]){
return JSON.stringify(responseJSON.features[0].attributes.KmIni);
}
else{
return "";
}
}
}
}
This script works and shows me the value I want the problem comes when publishing the survey through the mobile device that gives me the failure mentioned above and does not allow me to send it.
thanks in advance to all of you who participate to get the solution.
Regards
En Español:
Hola,
he creado una encuesta en SURVEY123, y me da el siguiente error: STRING OR BINARY DATA WOULD BE TRUNCATED. THE STATEMENT HAS BEEN TERMINATED. he mirado las soluciones que están subida al foro y no me han funcionado, he cambiado la longitud del campo, he cambio el tipo de este y me sigue dando el mismo error.
mi caso es el siguiente:
he creado una encuesta para la supervisión de vehículos y poseo un campo que se llama kilómetros iniciales.
me gustaría que este campo se rellene con el valor anterior que se ha puesto, para ello se ha realizado un script en JavaScript (gracias Ismael Chivite por la ayuda).
function getLastGeneratorReading(Parte_de_vehiculo,token){
var xmlhttp = new XMLHttpRequest();
var params = "/query?";
params = params + "where=Parte_de_vehiculo='" + Parte_de_vehiculo + "'&outFields=KmIni"
params = params + "&returnGeometry=false&orderByFields=OBJECTID DESC&resultRecordCount=1&f=json";
if (token ){
params = params + "&token=" + token ;
}
var url = featureLayer + params;
xmlhttp.open("GET",url,false);
xmlhttp.send();
if (xmlhttp.status!==200){
return (xmlhttp.status);
} else {
var responseJSON=JSON.parse(xmlhttp.responseText)
if (responseJSON.error){
return (JSON.stringify(responseJSON.error));
} else {
if (responseJSON.features[0]){
return JSON.stringify(responseJSON.features[0].attributes.KmIni);
}
else{
return "";
}
}
}
}
este script funciona y me muestra el valor que quiero el problema viene a la hora de publicar la encuesta a través del dispositivo móvil que me arroja el fallo mencionado con anterioridad y no me permite enviarla.
gracias de antemano a todos los que participéis para conseguir la solución.
Saludos