You are viewing limited content. For full access, please sign in.

Question

Question

SDK - data field

SDK
asked on October 30, 2015

Hi, 

 

I have a customer that is trying to use the SDK to write a date field. Can some one please give some guidance on the code below? 

 

Thanks,

 

Brian

 

We are attempting to use the java laserfice SDK interface to write a date field, and it keeps failing. See code snippet below. (Running Laserfiche 9.2 client / server /sdk). Can you help us figure out the correct method to write a date?

 

Thanks!

 

Below is the snippet of the java code. It throws 'Bad Field Value' error.

 

   Document document = Document.create(....);

 

   Calendar dateValue = Calendar.getInstance(TimeZone.getTimeZone("GMT"));

   dateValue.set(2015, 11, 15, 0, 0, 0);

 

   FieldValueCollection fvc = new FieldValueCollection();

   Field effectiveDate = new Field("Effective Date", session);

   fvc.add(effectiveDate, dateValue);

 

   document.setFields(fvc);

   document.save();

0 0

Replies

replied on October 30, 2015

I'm not familiar with the Java SDK, but with the .Net one you typically don't instantiate a new FielValueCollection.  Instead you call GetFieldValues() on the entry to get a reference to its collection, and then you don't call SetFields() since it already has that collection assigned to it.

0 0
replied on October 30, 2015

Not sure if this is an issue as well, but the Date field (in RA at least) takes a Date object as its input and you are trying to pass it a Calendar object.  You may need to use the Calendar.GetTime() function to get a Date object.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.