Methods | ScriptContext.TryGetOrCreateField(String, ChoiceFieldItemType, FieldItem) Method
Gets or creates the field matching both the given name and choice type. A return value indicates an existing field with type was found or a new field instance was created successfully.
Syntax
C#
Copy
public bool TryGetOrCreateField( string fieldName, ChoiceFieldItemType choiceFieldItemType, out FieldItem outputField )
Parameters
fieldName String
The name of the field.
choiceFieldItemType choiceFieldItemType
The choice type of the field.
outputField FieldItem
When this method returns, contains the result of an existing or created field.
Return Value
Booleantrue if a field with the name and choice type found, or created by this method; otherwise, false.
Exceptions
| Exception | Condition |
|---|---|
| Exception | Thrown when a matching field name exists but the choice type does not match the field type. |
Remarks
Calls GetField(String) to check if the field exists, then checks if the ChoiceFieldItemType matches the existing field. When neither match, calls CreateField(String, ChoiceFieldItemType) to create a new field instance.
See Also
Reference
ScriptContext Class
TryGetOrCreateField Overload
Compiled.EDD.Scripting Namespace