-
Notifications
You must be signed in to change notification settings - Fork 1
GenerateEntity
hso-d365 generate Entity <name> [--skipForms] [--entityLogicalName x]
CLI Command 'generate Entity' generates an Entity. The flag --skipForms is optional. When set, the command will not generate the forms files and .formContext.ts file.
Following files will be generated:
- src/[name]/[name].enum.ts
- src/[name]/[name].formContext.ts
- src/[name]/[name].model.ts
- src/[name]/[name].service.ts
- src/[name]/build.json
- src/[name]/[formName]/[formName].ts
- src/[name]/[formName]/[formName].form.ts
- src/[name]/[formName]/[formName].formContext.ts
In this file you can turn components on/off.
This is the root file for every form. It mentions the function you have to add to your D365 form or ribbon:
- onLoad function for your form (take care to check the 'pass formcontext' checkbox)
- myRibbonMethod for your ribbon Normally you don't touch this file that much.
This is the file for form logic. The onLoad is the starting point for all your business logic.
import {Translation} from '../../translation/Translation';
import {AccountService} from '../Account.service';
import {AccountModel} from '../Account.model';
import {AccountHSOFormContext} from './AccountHSO.formContext';
export class AccountHSOForm extends AccountHSOFormContext {
static async onLoad(executionContext: Xrm.Events.EventContext): Promise<void> {
const accounts: AccountModel[] = await AccountService.retrieveMultipleRecords({
select: ['name', 'description'],
filters: [{
type: 'and',
conditions: [{
attribute: 'name',
operator: 'eq',
value: 'test'
}]
}]
});
for (const account of accounts) {
console.log(`${account.name} has description ${account.description});
}
}
}
This file contains all fields/NavigationPropertyNames for the odata query. The [name].service.ts class needs it.
export interface AccountModel extends Model {
name?: string;
description?: string;
}
This file wraps the Xrm.WebApi methods and also knows the logicalName. Here you can add [name] Entity specific API calls and actions. Normally you use the Service class in your Form class instead of using the WebApi class directly. See more about WebApi.
Use command
hso-d365 generate Entity --help