cancel
Showing results for 
Search instead for 
Did you mean: 

Set date to property through webscript fails ISOFormat

shikarishambu
Champ in-the-making
Champ in-the-making
I am trying to upload a document into the repository using a custom webscript derived from sample/upload. I have a date property that I need to set. I have tried to set it directly, provide ISOFormat but I still get the error. What is the correct format to be used to set the date?

Here is how the date value is formated using date.format.js script function

//unout is 3/4/2010
function fnToISO(dt) {
   var nDate = new Date(dt);
   return nDate.format("isoDateTime");
}


Here is the error


file:D:/Alfresco/tomcat/shared/classes/alfresco/extension/templates/webscripts)': The property valu
e is not compatible with the type defined for the property:
   property: Name: {http://www.stepsoln.com/model/content/1.0}effectivedate
Title: null
Description: null
Default Value: null
DataType Name: {http://www.alfresco.org/model/dictionary/1.0}date
ContainerClass Name: {http://www.mymodel.com/model/content/1.0}doc
isMultiValued: false
isMandatory: false
isMandatoryEnforced: false
isProtected: false
isIndexed: true
isStoredInIndex: false
isIndexedAtomically: true
indexTokenisationMode: TRUE

   value: 2010-03-04T00:00:00
   value type: class java.lang.String
        at org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:6
13)
        at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:165)
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
Try to use the Date constructor with all the arguments:
Date yourCustomDate = new Date("2010","02","25");
Now it should work.

Hope this helps.

shikarishambu
Champ in-the-making
Champ in-the-making
The issue was due to the fact that Alfresco automatically converts the date passed to ISOFormat. I don't need to do that in my script while trying to upload/ update. I need to do that for search