Skip to main content

TypedValue

A typed value. Typically used to represent the value of a property or an evaluated expression.

NameDescriptionType
is_null_valueIs the value NULL.boolean
typeData type.Datatype
dataThe value data as a union, if not NULL.TypedValueUnion

Helper Methods and Properties

⚠️ Note

These helper methods and properties are available when using the npm package @m-filescorporation/uix-vault-messages. Install it in your project to use these helpers. For more information, see Overview/VaultMessages/.

Factory Methods

MethodDescriptionParametersReturns
CreateCreates a new TypedValue of the specified type.type: Datatype
value: TypedValueValueMap[T]
TypedValue
TextCreates a new TypedValue of type Text.value: TypedValueValueMap[Datatype.DATATYPE_TEXT]TypedValue
FloatCreates a new TypedValue of type Real Number (Float).value: TypedValueValueMap[Datatype.DATATYPE_REAL_NUMBER]TypedValue
BoolCreates a new TypedValue of type Boolean.value: TypedValueValueMap[Datatype.DATATYPE_BOOLEAN]TypedValue
LookupCreates a new TypedValue of type Lookup.value: TypedValueValueMap[Datatype.DATATYPE_LOOKUP]TypedValue
DateCreates a new TypedValue of type Date.value: TypedValueValueMap[Datatype.DATATYPE_DATE]TypedValue
TimestampCreates a new TypedValue of type Timestamp.value: TypedValueValueMap[Datatype.DATATYPE_TIMESTAMP]TypedValue
MultiLookupCreates a new TypedValue of type Multi-Select Lookup.value: TypedValueValueMap[Datatype.DATATYPE_MULTI_SELECT_LOOKUP]TypedValue
IntCreates a new TypedValue of type Integer.value: TypedValueValueMap[Datatype.DATATYPE_INTEGER]TypedValue
MultiTextCreates a new TypedValue of type Multi-Line Text.value: TypedValueValueMap[Datatype.DATATYPE_MULTI_LINE_TEXT]TypedValue
TimeCreates a new TypedValue of type Time.value: TypedValueValueMap[Datatype.DATATYPE_TIME]TypedValue

Instance Methods

MethodDescriptionParametersReturns
SetSet the value and type of the TypedValue.type: Datatype
value: TypedValueValueMap[T]
void
AsBoolGet the value as a boolean. If the value is null, returns null. If the value is not a boolean, throws an error.boolean | null
AsNumberGet the value as a number. If the value is null, returns null. If the value is not a number, throws an error.number | null
AsDateGet the value as a Date. If the value is null, returns null. If the value is not a date/time/timestamp, throws an error.Date | null
AsTextGet the value as text. If the value is null, returns null. If the value is not convertible to text, throws an error.string | null
AsLookupGet the value as a Lookup. If the value is null, returns null. If the value is not a lookup, throws an error.Lookup | null
AsLookupsGet the value as an array of Lookups. If the value is null, returns null. If the value is not a multi-select lookup, throws an error.Lookup[] | null
GetLookupIDIf the TypedValue is of type Lookup, get the ID of the lookup. If the value is null, returns null. If the value is not a lookup, throws an error.number | null
SetTextSet the value as text.value: TypedValueValueMap[Datatype.DATATYPE_TEXT]void
SetMultiTextSet the value as multi-line text.value: TypedValueValueMap[Datatype.DATATYPE_MULTI_LINE_TEXT]void
SetBoolSet the value as a boolean.value: TypedValueValueMap[Datatype.DATATYPE_BOOLEAN]void
SetIntSet the value as an integer.value: TypedValueValueMap[Datatype.DATATYPE_INTEGER]void
SetDateSet the value as a date.value: TypedValueValueMap[Datatype.DATATYPE_DATE]void
SetLookupSet the value as a lookup.value: TypedValueValueMap[Datatype.DATATYPE_LOOKUP]void
SetFloatSet the value as a real number.value: TypedValueValueMap[Datatype.DATATYPE_REAL_NUMBER]void
SetMultiLookupSet the value as a multi-select lookup.value: TypedValueValueMap[Datatype.DATATYPE_MULTI_SELECT_LOOKUP]void
SetTimeSet the value as a time.value: TypedValueValueMap[Datatype.DATATYPE_TIME]void
SetTimestampSet the value as a timestamp.value: TypedValueValueMap[Datatype.DATATYPE_TIMESTAMP]void

Properties

PropertyTypeDescription
IsNullbooleanIs the value null?

Creating Objects

// Creates a new TypedValue of the specified type.
const result = TypedValue.Create(0);

// Creates a new TypedValue of type Text.
const result = TypedValue.Text("example text");

// Creates a new TypedValue of type Real Number (Float).
const result = TypedValue.Float(42);

// Creates a new TypedValue of type Boolean.
const result = TypedValue.Bool(true);

// Creates a new TypedValue of type Lookup.
const result = TypedValue.Lookup(new Lookup());

// Creates a new TypedValue of type Date.
const result = TypedValue.Date(new Date());

// Creates a new TypedValue of type Timestamp.
const result = TypedValue.Timestamp(new Date());

// Creates a new TypedValue of type Multi-Select Lookup.
const result = TypedValue.MultiLookup([]);

// Creates a new TypedValue of type Integer.
const result = TypedValue.Int(42);

// Creates a new TypedValue of type Multi-Line Text.
const result = TypedValue.MultiText("example text");

// Creates a new TypedValue of type Time.
const result = TypedValue.Time(new Date());

Working with Objects

// Extension helpers for TypedValue instances
// Set the value and type of the TypedValue.
const result = typedvalueInstance.Set(0);

// Get the value as a boolean. If the value is null, returns null. If the value is not a boolean, throws an error.
const result = typedvalueInstance.AsBool();

// Get the value as a number. If the value is null, returns null. If the value is not a number, throws an error.
const result = typedvalueInstance.AsNumber();

// Get the value as a Date. If the value is null, returns null. If the value is not a date/time/timestamp, throws an error.
const result = typedvalueInstance.AsDate();

// Get the value as text. If the value is null, returns null. If the value is not convertible to text, throws an error.
const result = typedvalueInstance.AsText();

// Get the value as a Lookup. If the value is null, returns null. If the value is not a lookup, throws an error.
const result = typedvalueInstance.AsLookup();

// Get the value as an array of Lookups. If the value is null, returns null. If the value is not a multi-select lookup, throws an error.
const result = typedvalueInstance.AsLookups();

// If the TypedValue is of type Lookup, get the ID of the lookup. If the value is null, returns null. If the value is not a lookup, throws an error.
const result = typedvalueInstance.GetLookupID();

// Set the value as text.
const result = typedvalueInstance.SetText("example text");

// Set the value as multi-line text.
const result = typedvalueInstance.SetMultiText("example text");

// Set the value as a boolean.
const result = typedvalueInstance.SetBool(true);

// Set the value as an integer.
const result = typedvalueInstance.SetInt(42);

// Set the value as a date.
const result = typedvalueInstance.SetDate(new Date());

// Set the value as a lookup.
const result = typedvalueInstance.SetLookup(new Lookup());

// Set the value as a real number.
const result = typedvalueInstance.SetFloat(42);

// Set the value as a multi-select lookup.
const result = typedvalueInstance.SetMultiLookup([]);

// Set the value as a time.
const result = typedvalueInstance.SetTime(new Date());

// Set the value as a timestamp.
const result = typedvalueInstance.SetTimestamp(new Date());

// Is the value null?
const isnull = typedvalueInstance.IsNull;

Example

{
"is_null_value": false,
"type": 15 /* Enum: Datatype */,
"data": {
"acl": {
"checked_out_to_user": 0,
"is_fully_authoritative": false,
"custom_component": {
"named_acl_id": 0,
"has_named_acl": false,
"current_user_id": 0,
"has_current_user": false,
"permissions": [] /* Array of AccessControlEntry */,
"overridability_permissions": [] /* Array of AccessControlEntry */,
"status": {
"all": false,
"deleted": false,
"source_item_linked_via_pseudo_users": false
}
},
"restrictive_components": [] /* Array of AccessControlListComponentMapEntry */,
"secondary_access_control_list": {} /* AccessControlList */,
"additive_components": [] /* Array of AccessControlListComponentMapEntry */
}
}
}