TypedValue
A typed value. Typically used to represent the value of a property or an evaluated expression.
| Name | Description | Type |
|---|---|---|
is_null_value | Is the value NULL. | boolean |
type | Data type. | Datatype |
data | The 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
| Method | Description | Parameters | Returns |
|---|---|---|---|
Create | Creates a new TypedValue of the specified type. | type: Datatype value: TypedValueValueMap[T] | TypedValue |
Text | Creates a new TypedValue of type Text. | value: TypedValueValueMap[Datatype.DATATYPE_TEXT] | TypedValue |
Float | Creates a new TypedValue of type Real Number (Float). | value: TypedValueValueMap[Datatype.DATATYPE_REAL_NUMBER] | TypedValue |
Bool | Creates a new TypedValue of type Boolean. | value: TypedValueValueMap[Datatype.DATATYPE_BOOLEAN] | TypedValue |
Lookup | Creates a new TypedValue of type Lookup. | value: TypedValueValueMap[Datatype.DATATYPE_LOOKUP] | TypedValue |
Date | Creates a new TypedValue of type Date. | value: TypedValueValueMap[Datatype.DATATYPE_DATE] | TypedValue |
Timestamp | Creates a new TypedValue of type Timestamp. | value: TypedValueValueMap[Datatype.DATATYPE_TIMESTAMP] | TypedValue |
MultiLookup | Creates a new TypedValue of type Multi-Select Lookup. | value: TypedValueValueMap[Datatype.DATATYPE_MULTI_SELECT_LOOKUP] | TypedValue |
Int | Creates a new TypedValue of type Integer. | value: TypedValueValueMap[Datatype.DATATYPE_INTEGER] | TypedValue |
MultiText | Creates a new TypedValue of type Multi-Line Text. | value: TypedValueValueMap[Datatype.DATATYPE_MULTI_LINE_TEXT] | TypedValue |
Time | Creates a new TypedValue of type Time. | value: TypedValueValueMap[Datatype.DATATYPE_TIME] | TypedValue |
Instance Methods
| Method | Description | Parameters | Returns |
|---|---|---|---|
Set | Set the value and type of the TypedValue. | type: Datatype value: TypedValueValueMap[T] | void |
AsBool | Get the value as a boolean. If the value is null, returns null. If the value is not a boolean, throws an error. | boolean | null | |
AsNumber | Get the value as a number. If the value is null, returns null. If the value is not a number, throws an error. | number | null | |
AsDate | 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. | Date | null | |
AsText | Get the value as text. If the value is null, returns null. If the value is not convertible to text, throws an error. | string | null | |
AsLookup | Get the value as a Lookup. If the value is null, returns null. If the value is not a lookup, throws an error. | Lookup | null | |
AsLookups | 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. | Lookup[] | null | |
GetLookupID | 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. | number | null | |
SetText | Set the value as text. | value: TypedValueValueMap[Datatype.DATATYPE_TEXT] | void |
SetMultiText | Set the value as multi-line text. | value: TypedValueValueMap[Datatype.DATATYPE_MULTI_LINE_TEXT] | void |
SetBool | Set the value as a boolean. | value: TypedValueValueMap[Datatype.DATATYPE_BOOLEAN] | void |
SetInt | Set the value as an integer. | value: TypedValueValueMap[Datatype.DATATYPE_INTEGER] | void |
SetDate | Set the value as a date. | value: TypedValueValueMap[Datatype.DATATYPE_DATE] | void |
SetLookup | Set the value as a lookup. | value: TypedValueValueMap[Datatype.DATATYPE_LOOKUP] | void |
SetFloat | Set the value as a real number. | value: TypedValueValueMap[Datatype.DATATYPE_REAL_NUMBER] | void |
SetMultiLookup | Set the value as a multi-select lookup. | value: TypedValueValueMap[Datatype.DATATYPE_MULTI_SELECT_LOOKUP] | void |
SetTime | Set the value as a time. | value: TypedValueValueMap[Datatype.DATATYPE_TIME] | void |
SetTimestamp | Set the value as a timestamp. | value: TypedValueValueMap[Datatype.DATATYPE_TIMESTAMP] | void |
Properties
| Property | Type | Description |
|---|---|---|
IsNull | boolean | Is 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 */
}
}
}