How to create entities with generalization(System entities) through Model SDK ?

0
Hello Everyone,   Did anyone try creating generalized entities (System entities) through Model SDK ? I want to generalize my entities with system entities like Image or FileDocument. I couldn’t find a way, tried the below code from reverse engineering tool. Please let me know if anyone tried this. var generalization = domainmodels.Generalization.create(model); ***** The below line from reverse engineering tool is not supported as mentioned in the below comment ***** // Note: this is an unsupported internal property of the Model SDK which is subject to change. generalization.__generalization.updateWithRawValue("System.Image"); //generalization with entities other than System module (This works fine) generalization. Generalization=model.findEntityByQualifiedName("MyFirstModule.RandomEntity");   regards, Suresh Konapuram.
asked
3 answers
1

Hi Suresh,

This should work:

export async function createGeneralization(model: IModel, moduleName: string, entityName: string) {
    const domainModelInterface = model.allDomainModels().filter((dm) => dm.containerAsModule.name === moduleName)[0];
    const domainModel = await domainModelInterface.load();
    const newEntity = domainmodels.Entity.createIn(domainModel);
    const generalization = domainmodels.Generalization.create(model);
    const generalizedEntity = model.findEntityByQualifiedName("System.Image");
    if (generalizedEntity) {
        generalization.generalization = generalizedEntity;
    }
    newEntity.name = entityName;
    newEntity.generalization = generalization;
}

 

answered
1

+1 Same Problem as OP. Cannot find any System Entites, and System as a module is also not to be found.

image.png

answered
0

Workaround:

Create a entity (in studio) that generalises System.FileDocument or what you need, and in your Code use that to Generalise from:

image.png

 

-> use workingModel.findEntityByQualifiedName("<yourModule>.NotesAttachment") or what your entity is called.

Don't forget that you have to commit the entity so that your SDK knows of the entity.

answered