Implement Domain Services

Within a domain service implementation, you can access the modelled input properties and process any logic. Typical logic in domain services would be e. g. loading of data from the repo and processing the data or calling instance and factory commands. Additionally it is also possible to define the output of the service. Both input and output is restricted to what has been modelled in the Solution Designer.

  /**
   * Domain service execution
   */
  public async execute(): Promise<void> {

    // Get the input properties
    const { property1, property2, id } =  this.input;

    // Get an instance by ID
    const myInstance = await this.repo.nsacrnm.EntityIdentifier.findById(id);

    // trigger instanceCommand
    await myInstance.MyCommand();

    // fill output of service with some data
    this.output = this.factory.entity.order.ServiceIdentifier_Output();
    this.output.prop1 = property1;
    this.output.prop2 = property2;
  }