cancel
Showing results for 
Search instead for 
Did you mean: 

Property Conversion failed

surya_nagaraj
Champ on-the-rise
Champ on-the-rise

Hi,

Not able to set property of type Datetime in Nuxeo using Automation Scripting (JavaScript). Below is the code snippet:

function run(input, params) {

var d2 = new Date();
d2.setFullYear(d2.getFullYear()+7);

Document.SetProperty(input,{
	/*required:true - type: string*/
	'xpath':"doc:start_date",
	/*required:false - type: boolean*/
	'save':true,
	/*required:false - type: serializable*/
	'value':d2
});

} Below error is occured in Nuxeo, Please suggest how to do property convert:

Caused by: org.nuxeo.ecm.core.api.model.PropertyConversionException: Property Conversion failed from class org.nuxeo.ecm.automation.core.util.DataModelProperties to class java.util.Calendar at org.nuxeo.ecm.core.api.model.impl.primitives.DateProperty.normalize(DateProperty.java:66) at org.nuxeo.ecm.core.api.model.impl.AbstractProperty.setValue(AbstractProperty.java:311) at org.nuxeo.ecm.automation.core.operations.document.SetDocumentProperty.run(SetDocumentProperty.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

1 REPLY 1

Yousuf_Nejati
Star Contributor
Star Contributor

Hi Surya,

I believe your JS Date object is not recognized as an instance of Java Calendar.

The exception is being thrown here:

@Override
public Serializable normalize(Object value) throws PropertyConversionException {
if (isNormalized(value)) {
return (Serializable) value;
}
if (value.getClass() == Date.class) {
Calendar cal = Calendar.getInstance();
cal.setTime((Date) value);
return cal;
}
if (value instanceof String) {
String string = (String) value;
if (string.length() == 0) {
return null;
}
return (Calendar) field.getType().decode(value.toString());
}
throw new PropertyConversionException(value.getClass(), Calendar.class);
}

@Override
public boolean isNormalized(Object value) {
return value == null || value instanceof Calendar;
}


source: https://github.com/nuxeo/nuxeo/blob/434093e97825bf7e02578efd428e71f588704f20/nuxeo-core/nuxeo-core-a...

Hope this helps.

-Yousuf

Getting started

Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.