BusinessObjectBase

BusinessObjectBase TypeScript Class Reference

Overview

BusinessObjectBase class is a base class for all business objects. The developer defines the business objects within the app in JSON files (Business Object Definition) under the Business Objects folder in the app's project. The Dynamics Mobile framework will generate corresponding TypeScript implementations, where each of the Business Objects JSON definitions will be represented by a corresponding TypeScript class. Each of these TypeScript classes extends BusinessObjectBase class.

Don't create BusinessObjectBase class directly - use the automatically generated ancestors.

Name

Type

string

string

string

string

string

string

boolean

number

☑️ static appCode: string

Property 'appCode' contains the unique of the application where the business object was generated.

☑️ static boName: string

Property 'boName' contains the name of the business object

☑️ static boSyncName: string

Property 'boSyncName' contains the synchronization tag of the business object as specified in the Business Object's JSON definition in the SyncTag property.

☑️ static boTableName: string

Property 'boTableName' contains the name of the physical database table , where the records for the business object will be stored. Can be used in row level queries executed via SqlQueryService class.

☑️ static members: Array<BusinessObjectMember>

the property contains metadata for the properties of the business object as they are defined in the business object JSON definition.

☑️ DMS_ROWID: string

DMS_ROWID property is the unique identifier of the business object instance and is used as a primary key field in the corresponding record in the mobile database. DMS_ROWID is a string, which contains unique UUID( GUID) value. The value an be either automatically generated by the framework when the BusinessObjectBase.add method is called or manually provided by the developer by using the uuid npm or similar uuid generation algorithm.

☑️ dontPostToSyncLog: boolean

Property 'dontPostToSyncLog' is false by default and specifies if the sending of the business object instance must be skipped during changes of the instance. Dynamics Mobile framework will automatically generate and send synchronization packet for each business instance when the business object instance add, update and delete methods are called. if property dontPostToSyncLog is set to true, the framework will not send synchronization packet to the backend, which will make so that the change of the business object will not be reflected on the backend.

☑️ state: 0 | 1 | 2 | 3

Property 'state' represent the state of the business object.

  • 0 - not modified

  • 1 - created (inserted)

  • 2 - updated

  • 3 - deleted

Call to the methods add, update, delete will change the state property accordingly.

▶️ static query(): DbQuery<T>

The query method will return generic DbQuery instance bound to the current business object instance. This allows the developer to query the local database.

See DbQuery for more information how to use DbQuery

static livelinkQuery(): LiveLinkQuery<T>

The query method will return generic LiveLinkQuery instance bound to the current business object instance. This allows the developer to query the local database.

See LiveLinkQuery for more information how to use it

▶️ async add(): Promise<void>

The method persists the entity by inserting it as new record into the local on-device database. The method will also generate synchronization packet to notify the backend for a change. The method works in offline mode and the sync packet will be sent to Dynamics Mobile Portal and/or ERP asynchronously once a network connection is detected.

▶️ async update(): Promise<void>

The method persists the entity by updating it into the local on-device database by using the primary key (DMS_ROWID). The method will also generate synchronization packet to notify the backend for a change. The method works in offline mode and the sync packet will be sent to Dynamics Mobile Portal and/or ERP asynchronously once a network connection is detected.

▶️ async delete(): Promise<void>

The method deletes the entity from the local on-device database by using the primary key (DMS_ROWID). The method will also generate synchronization packet to notify the backend for a change. The method works in offline mode and the sync packet will be sent to Dynamics Mobile Portal and/or ERP asynchronously once a network connection is detected.

How to use

import { View, DocumentSeriesService, UserInterfaceService } from '@dms';
import { Invoice } from '@dms-bo';

// it is supposed that there is defined business object Customer in the Business Object folder

@View()
export class MyView {

 //declare observable variable - supposed to be bi-directionally databound to the  corresponding view ( html)
  public customer: ko.Observable<Customer>;

  constructor(
      private DocumentSeriesService: DocumentSeriesService,
      private UserInterfaceService: UserInterfaceService){
        //create 'empty' instance of the customer and provide it to the observable to make sure it is "connected" to the UI
        this.customer = ko.observable<Customer>(new Customer());
  }

//called to validate the UI form
  public async validate(){

    //valaidate the user input.
    //it is supposed that the customer properties are automatically propagated via data-bind

    if(!this.customer().no || !this.customer().name) {
      return false;
    }
    else{
        return true;
    }

  }

//called to persist the UI form
  public async commit(){
      //create the customer in the database
      await this.customer().add();
  }

Last updated

Dynamics Mobile provided by Mobile Affairs Ltd. | 1712 Sofia, Bulgaria, Alexander Malinov 51 | sales@dynamicsmobile.com