Reference objects are generally used in 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); 

Type parameters

Hierarchy

Properties

Readonly code

code: string

App code of the URL’s target (the app’s code).

Readonly id

id: string

ID of the URL’s target.

Readonly namespace

namespace: string

Namespace of the URL target (the code of the workspace that the app belongs to).

Methods

fetch

  • fetch(): Promise<I>
  • Request complete data of an arbitrary app item.

    const any_app_full = await Context.data.any_app.fetch();
    

    Returns Promise<I>