Skip to main content
Version: 1.2.0

Working with FieldObjects

Nearly all ScriptLink use cases invlove working with FieldObjects whether reading, setting, or modifying. The AvatarScriptLink.NET library helps with these very common tasks.

Read the Value

The GetFieldObject method will return the FieldValue from the matching FieldObject in the CurrentRow.

Read the Value of a FieldObject
var clone = _optionObject.Clone();

string fieldValue = clone.GetFieldValue("123.45");

return clone.ToReturnOptionObject();

Set the Value

When setting the value of a FieldObject the SetFieldObject method will also update the RowAction to EDIT for you.

Read a FieldValue
var clone = _optionObject.Clone();

clone.SetFieldValue("123.45", "My new value.");

return clone.ToReturnOptionObject();

Verify Presence

The IsFieldPresent can be used to assist with validation and unit testing.

Verify a Field is Present before Modification
var clone = _optionObject.Clone();

string fieldNumber = "123.45";
if (clone.IsFieldPresent(fieldNumber))
clone.SetFieldValue(fieldNumber, "My new value.");

return clone.ToReturnOptionObject();

Set Statuses

There are three different statuses that can be set on a FieldObject: Enabled, Locked, and Required.

Set/Change the Status of a FieldObject
var clone = _optionObject.Clone();

string fieldNumber = "123.45";

clone.SetEnabledField(fieldNumber) // or clone.SetDisabledField(fieldNumber)
clone.SetLockedField(fieldNumber) // or clone.SetUnlockedField(fieldNumber)
clone.SetRequiredField(fieldNumber); // or clone.SetOptionalField(fieldNumber)

return clone.ToReturnOptionObject();

You can also set the status of multiple FieldObjects in a single request.

Set/Change the Status of a FieldObject
var clone = _optionObject.Clone();

List<string> fieldNumbers = new List<string>() {
"123.45",
"123.46",
"123.54"
};

clone.SetEnabledFields(fieldNumbers) // or clone.SetDisabledFields(fieldNumbers)
clone.SetLockedFields(fieldNumbers) // or clone.SetUnlockedFields(fieldNumbers)
clone.SetRequiredFields(fieldNumbers); // or clone.SetOptionalFields(fieldNumbers)

return clone.ToReturnOptionObject();

Verify Statuses

There are also helper methods to help verify the current state of a FieldObject.

  • IsFieldEnabled
  • IsFieldLocked
  • IsFieldRequired
Verify the Status of a FieldObject
var clone = _optionObject.Clone();

string fieldNumber = "123.45";

if (!clone.IsFieldRequired(fieldNumber))
clone.SetRequiredField(fieldNumber);

return clone.ToReturnOptionObject();