Javascript Document Tasks :: Casting issue

View: New views
3 Messages — Rating Filter:   Alert me  

Javascript Document Tasks :: Casting issue

by Alex Bleasdale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi - I'm hoping someone can help:

I'm creating a document task based on a query - I'm trying to batch update several "Width" fields.   I've written something like this:

var document = repository.getDocument(variantKey, true);
document.setField('Width', 750);
document.save();

But I get this exception:

org.mozilla.javascript.WrappedException: Wrapped org.outerj.daisy.repository.DocumentTypeInconsistencyException: The supplied value for the field "Width" is not of the correct type. Expected was a long (java.lang.Long) but got a java.lang.Double (#2)

Does anyone know how to get around casting issues using the Javascript document API?  

Thanks,
A

Re: Javascript Document Tasks :: Casting issue

by Lou Parisi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not familiar with the specific thing you are trying to do but I have seen similar exceptions for other things I have worked on and have resolved similar issues by explicitly creating the expected type specified in the exception .

document.setField('Width', new java.lang.Long(750));

Alex Bleasdale wrote:
I've written something like this:

document.setField('Width', 750);

But I get this exception:

org.mozilla.javascript.WrappedException: Wrapped org.outerj.daisy.repository.DocumentTypeInconsistencyException: The supplied value for the field "Width" is not of the correct type. Expected was a long (java.lang.Long) but got a java.lang.Double (#2)

Re: Javascript Document Tasks :: Casting issue

by Alex Bleasdale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That works perfectly - hopefully that will be useful for anyone else facing the same issue - thanks very much.