SDK Find and change entity

1
Looking for a way to find an entity and then to change the entity, using SDK. The resources I found are: https://community.mendix.com/link/questions/85732 https://docs.mendix.com/apidocs-mxsdk/mxsdk/loading-units-and-elements However, I am unable to use this to find the entity to be able to change it. EDIT Code: export async function findEntity(name: string, workingCopy: OnlineWorkingCopy) {     const entity = workingCopy.model().findEntityByQualifiedName(name);          if(entity !== null) {         return entity.load();     }     else console.error(`Could not find entity ${name}`); } The call is: const systemUser = await basic.findEntity('Administration.Account', workingCopy); This is where I then await the retrieval of the entity.
asked
2 answers
1

Theo,

the load() function is asynchronous and will not block the execution of the rest of your code.
You should await the result, or use a callback to access the loaded document (i.e. before trying to access the entity).

EDIT: You already had this link in your question (still a good read though).
The docs mention it here: https://docs.mendix.com/apidocs-mxsdk/mxsdk/loading-units-and-elements

Regards,

Jeroen

answered
0

I think this is what you are looking for: https://docs.mendix.com/apidocs-mxsdk/mxsdk/finding-things-in-the-model

 

It actually boils down to a one-liner:

const customerEntity = model.findEntityByQualifiedName("Customers.Customer");
answered