Reference objects are generally used in ** Arbitrary app** type fields in order to avoid loading
all the associated data at once.
You can use the RefItem.fetch method to retrieve the full app item object that is referenced.
If the app item is not found, the method returns an error that needs to be processed.
Example:
let appItem: any;
try {
appItem = await Context.data.any_app.fetch();
} catch (err) {
// Here the error needs to be processed // An error can be thrown, for example, when the item that the `RefItem` object references is not found
}
You can create a reference object using the following constructor:
const refItem = new RefItem(namespace, code, id);
Where:
— namespace is the workspace’s code.
— code is the code of the app.
— id is the unique ID of the app item.
If the app that contains the item that the RefItem object references is known, you can clearly specify the type of the target item in the constructor:
// A `RefItem` object that references a User item const refUserItem = new RefItem<UserItem> ('system', 'users', userId);
Reference object to an item of an arbitrary app
Reference objects are generally used in ** Arbitrary app** type fields in order to avoid loading all the associated data at once. You can use the RefItem.fetch method to retrieve the full app item object that is referenced. If the app item is not found, the method returns an error that needs to be processed. Example:
let appItem: any; try { appItem = await Context.data.any_app.fetch(); } catch (err) { // Here the error needs to be processed // An error can be thrown, for example, when the item that the `RefItem` object references is not found }You can create a reference object using the following constructor:
const refItem = new RefItem(namespace, code, id);Where: —
namespaceis the workspace’s code. —codeis the code of the app. —idis the unique ID of the app item. If the app that contains the item that theRefItemobject references is known, you can clearly specify the type of the target item in the constructor:// A `RefItem` object that references a User item const refUserItem = new RefItem<UserItem> ('system', 'users', userId);Type parameters
I: Item<ItemData>
Hierarchy
Properties
Readonly code
App code of the URL’s target (the app’s code).
Readonly id
ID of the URL’s target.
Readonly namespace
Link target namespace (the code of the app's workspace).
Methods
fetch
Request complete data of an arbitrary app item.
const any_app_full = await Context.data.any_app.fetch();Returns Promise<I>