Skip to content

Annotation

Niels Steenbeek edited this page Mar 24, 2020 · 4 revisions

Annotation

An annotation is a default Entity having specific logic to upsert an Annotation. No need to generate the entity and write parsing and upsert logic.

Annotation.service.ts

The Annotation.service.ts has two important methods to do the upsert:

  1. parseAnnotation(blob: Blob,...), which parses a blob to an AnnotationModel
  2. upserRecord(annotationModel: AnnotationModel), which inserts or updates the Annotation
  3. retrieveClone(id: string), which returns a clone of an existing one

Annotation.model.ts

import {Model} from '../WebApi/Model';
export interface AnnotationModel extends Model {
    annotationid?: string;
    documentbody?: string;
    filename?: string;
    mimetype?: string;
    notetext?: string;
    objectid?: {
        id: string;
        logicalName: string;
    };
    subject?: string;
    versionnumber?: string;
}

Example

const entity = formContext.data.entity,
      annotation = await AnnotationService.parseAnnotation(blob, 'MyFilename.png', 
                             entity.getId(), entity.getEntityName());
await  AnnotationService.upsertRecord(annotation);
Clone this wiki locally