This is an API question: how do I get a list of fields that are not tied to templates. All the API documentation has examples for getting fields tied to templates. How do I access field definitions that are not tied to a template?
Question
Question
Getting Laserfiche field information for fields not tied to a particular template
Answer
It sounds like you're looking to get the field values set on an entry. If you want all of the field values regardless of whether or not they're a part of a template, the EntryInfo object has a method called GetFieldValues.
If you need only the field values set on an entry that aren't a part of a template, you could test the results of GetFieldValues using FieldInfo's GetContainingTemplates, which returns a collection of the templates that contain the field in question.
More information about both EntryInfo and FieldInfo can be found in the "Laserfiche SDK 9.0" manual installed with the SDK under ".NET APU Object Reference".
Replies
If you prefer LFSO, the SDK documentation mentions that you can set fields independently from the template by using their names and has examples of setting fields by name.
' Gets the document from the root folder. Dim Doc As LFDocument = DB.GetEntryByPath("\Doc1") ' Gets the FieldData object for the document. Dim DocMetaData As LFFieldData = Doc.FieldData ' Gets a field as a string, by name. Dim sVal1 As String = Fields.FieldAsString("Number") ' Gets a field as a date object by name. Dim oVal1 As System.DateTime = Fields.Field("Date") ' Locks the object for writing. DocMetaData.LockObject(Lock_Type.LOCK_TYPE_WRITE) ' Defines new values for fields. DocMetadata.Field("Document")= "12" ' Sends changes to server. DocMetaData.Update() ' Unlocks the object and disposes of all handles. Doc.Dispose()
We are a VAR. Urgent assistance needed for a demo scheduled for tomorrow. Our code which utilizes LFSO80 to inteface wtih LF9.0 to update template fields is incurring an exception at FieldData.Update() with this error: The parameter is out of range or too long. Code has not changed in a long time and it used to work just fine.
This usually means that you're trying to save a value longer than the maximum size of the field (for ex, a 10 character string into a 7 character field) or the wrong type of data for the field (a string into a number field).
Check the value that you are updating the field with. Confirm that it falls within range of the field. Meaning, if it's a text field that you are updating, make sure the length of the value doesn't exceed the field width, etc.