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

Question

Question

Date format error

SDK
asked on April 2, 2014

I am trying to update a FieldValueCollection with a date value to a data type of date.  I am getting the following error.

 

Multistatus response. (9039)
Bad field value. (9017)
Another operation on which this operation depends failed. (9054)
Another operation on which this operation depends failed. (9054)

 

here is the code;

' ********** format date values ********** 4-2-14
                If mArray(z, 0) = "Date" Then
                    Dim s As Integer = InStr(IndexArray(z + 1).ToString, " ")
                    Dim curDate As Date = CDate(IndexArray(z + 1))
                    'Left(IndexArray(z + 1), s - 1)
                    IndexArray(z + 1) = curDate
                End If

                Console.WriteLine(mArray(z, 0) & " = " & IndexArray(z + 1))
                FVC.Add(mArray(z, 0).ToString, IndexArray(z + 1).ToString)
                EI.SetFieldValues(FVC)
                EI.Save()
            Next z

the error occurs at the EI.Save

 

if I change the field data type to text it works fine.  I have formatted the string to a date, and still no luck. any ideas?

 

Phil Joyce

0 0

Answer

SELECTED ANSWER
replied on April 2, 2014 Show version history

if your date value is a string object, you should be able to use Date.TryParse.

 

Here is an example:

        Dim sDate As String = "4-2-14"
        Dim dDate As Date
        Dim bResult As Boolean = Date.TryParse(sDate, dDate)
        If bResult Then
            MsgBox("Good" & Environment.NewLine & dDate.ToString)
        Else
            MsgBox("Bad")
        End If

So once you have a valid date in a date object, you can then pass the date object as the value in the FVC.Add call.

3 0
replied on October 12, 2017

RA is very sensitive to proper date formatting, where LFSO is not.  You can pass in a date as a string via LFSO, but not in RA.  It will throw a 9017/Bad Field Error, as happened here.  On the other hand, RA will convert a datetime value to a date only for a Date field, and accept the full datetime value in a DateTime field.

Ex: 06 July 2008 7:32:47 AM will store as 6/8/2008 in a Date field, and as 6/8/2008 7:32:47 AM in a DateTime field, using the same calls.

0 0

Replies

replied on April 2, 2014

in your code, you are using a ".ToString" to convert your date object to a string.  you need to keep it a date object to pass into the FVC.

 

FVC.Add(mArray(z, 0).ToString, IndexArray(z + 1).ToString)

should be

FVC.Add(mArray(z, 0).ToString, IndexArray(z + 1))

 

0 0
replied on April 3, 2014

Thanks for the Help Bert,

However this is not working here is the modified Code;

 If mArray(z, 0) = "Date" Then
                    Dim sDate As String = IndexArray(z + 1)
                    Dim dDate As Date
                    Dim bResult As Boolean = Date.TryParse(sDate, dDate)
                    If bResult Then
                        MsgBox("Good" & Environment.NewLine & dDate.ToString)
                        FVC.Add(mArray(z, 0).ToString, sDate)
                        EI.SetFieldValues(FVC)
                        EI.Save()
                    Else
                        MsgBox("Bad")
                    End If
                Else
                    Console.WriteLine(mArray(z, 0) & " = " & IndexArray(z + 1))
                    FVC.Add(mArray(z, 0).ToString, IndexArray(z + 1))
                    EI.SetFieldValues(FVC)
                    EI.Save()
                End If
            Next z

Your code returns a valid date. I realized my Array was set up as a string so I passed the actual sdate as date. Here is the validated date format Good 8/18/2003 12:00:00 AM.

 

When I pass The date to the FVC.Add I get the same error as before.  During my Loop I am adding several values to fields with data type Text (83), and these work perfectly it seems that the date field is not working.  If I change the data type to text the date works.  However when I change the data type in admin console all dates are deleted.

 

I am stumped as to what is going wrong.

 

Phil

0 0
replied on April 3, 2014

A couple things jump out at me:

  1. You're missing your parenthesis on the calls to ToString on lines 7 and 15. In fact, it looks like mArray holds strings, so why even call ToString on its values?
  2. You don't need to set the field values on your EntryInfo every time that you modify the collection. Your EI.SetFieldValues(FVC) and EI.Save() can be moved outside the loop.
  3. You appear to use IndexArray as a one-based array but mArray as a zero-based array. You should try to be consistent about your usage in array indexing to avoid the random +/-1. Off by one errors are easy to make without that added frustration.
  4. You're still adding sDate to FVC on line 7, I think you intend to add dDate.

I'd guess that (4) is causing your issue. That said, it may be something else but I'd need more info to know for sure. What are the contents of mArray? IndexArray? Are you using Date/Time or Date fields in the repository?

0 0
replied on April 3, 2014

Mathew,

Thanks, it was the wrong variable.  I needed dDate not sDate.  I changed that and now everything works.  The multi Dimensional array is used to create fields in LaserFiche that do not exist. the array contains data types and formatting info.  the IndexArray starts at index zero, how ever field indexes in LaserFiche are base 1.  The multi dimensional array is base zero.  That is the reason for the offset or 1.

 

Thanks again for the help!!!

Phil

0 0
replied on May 27, 2015

Could we use the same sort of code within the JavaScript section of a Form?  We're running into the same error with one of our forms, and I'd like to "borrow" the above code in a format that would work for us.

Thanks to anyone who can help!

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

Sign in to reply to this post.