Click or drag to resize

ScriptContextTryConvertFieldType Method

Attempts to convert the provided field to a new field type. A return value indicates whether the field was converted successfully to the new field type.

Namespace:  Compiled.EDD.Scripting
Assembly:  Compiled.EDD.Scripting (in Compiled.EDD.Scripting.dll) Version: 7.6.1.3-5cb5c356
Syntax
C#
public bool TryConvertFieldType(
	FieldItem field,
	FieldItemType fieldType,
	bool logWarnings = false
)

Parameters

field
Type: Compiled.EDD.ScriptingFieldItem
The field to change and convert to a new field type.
fieldType
Type: Compiled.EDD.ScriptingFieldItemType
The new field type to convert values to.
logWarnings (Optional)
Type: SystemBoolean
When true warnings will be logged when data cannot be converted.

Return Value

Type: Boolean
true if conversion is successful; otherwise, false.

Implements

IScriptContextTryConvertFieldType(FieldItem, FieldItemType, Boolean)
Remarks
WARNING: Do not use method inside a document loop. Does not support Choice, Dynamic, or System fields. All the field values for the project documents will be parsed into the new field type. If an error occurs parsing an existing field value, this method will return false, and prior values and field type will be retained.
See Also