How to get meta data of entity with sql
Question

Hello everybody,

I am trying to get the meta data of a certain table with Sql.

In other words I want to get the name, the physical_name of the table(in this case the ActivityEvent) and so on without using the entity system data base. I can look for the table in Entity with: " Select {Entity}.* from {Entity} Where {Entity}.[Name] = "AcitivtyEevnt" but if I change the name "AcitivtyEvent" this would not work.

Is there any way to get the MetaData of the Database I reference in my sql?

Thank you very much in advance,

Roy

Hi Roy,

this sounds like something I did before, the way I read it, you have some view of your entity available (such as the input view of a wrapper action or something) and as part of what you log, you also want to retrieve the metadata of whatever entity your wrapper is for, without explicitly having to hardcode the entity name.

So if that's the case (you have some view, input/local/whatever available of your targeted entity), my solution might work for you.

See attached oml.  It might be slow, so probably not to be used in bulk/critical situations.

So what I'm doing is take any objectified entity view, turn it into xml, and search for the entity name in the xml.

Dorine


QDR_WhatsMyName.oml

Hi Roy,

With the following SQL statement you can get all the details from your entities. The Structure should be the "Entity" table and the Where condition should have the name defined in the Service Studio.


This should give you all the details you want.



But if I change the name of the database to something different than, ="User" or in my case = "ActivityEvent" this would not work because the name of the table in the condition is hard coded and not dynamic and will not change according the the new value.

I would like to create a query that gives me the metadata of an Entity without using it's name hard coded.

Thank you!

In that case you can use a query parameter.


I thought about it, but if for example I change the name of the table "user" to "user1", how do I connect the value of the input paramater of @entityname to the new value without changing it manually. 

It will still be hard coded but outside the sql query.

Thank you

Can you explain me what are you trying to accomplish here? 

Are you trying to build a screen where you can search for a specific entity? Do you want to show these fields for every entity that you have?

Instead of hard coding the "User" string to the query parameter, you can just add a variable there and is no longer hard coded. 

Eventually my goal is to log every change of an entity into a log service and one of the attr that i want to have is the entity ID. I know that I can get the Entity ID with the combination of espace id and Table name the therefore I am trying to get those two values. I manged to get Espace id by the action GetOwnerEspaceID. Now I am trying to get the entity id I am using without referencing the entity name directly for it can change. I thought I would be able to achieve that using sql because it when I use FROM {...} it references the database and not it's name.


I think your best option is through the SSKey attribute. This attribute is unique per table and is the same in all the environments.

You can also take a look at this forge component that can help you achieve what you want.


Hope this helps,

Pedro

Hi Roy,

this sounds like something I did before, the way I read it, you have some view of your entity available (such as the input view of a wrapper action or something) and as part of what you log, you also want to retrieve the metadata of whatever entity your wrapper is for, without explicitly having to hardcode the entity name.

So if that's the case (you have some view, input/local/whatever available of your targeted entity), my solution might work for you.

See attached oml.  It might be slow, so probably not to be used in bulk/critical situations.

So what I'm doing is take any objectified entity view, turn it into xml, and search for the entity name in the xml.

Dorine


QDR_WhatsMyName.oml

Thank you very much it is exactly what I have been looking for:)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.