How to find model of specific object through X++

Hi Experts,

Hope you are doing well.
I would just like to update you with new stuff which I have learnt recently. So, I will write a piece of code which returns model of specific object, in my case, I will use Class as object but you can use others objects as well. So, here you go.

static void jobGetObjectModel(Args _args)
{
SysDictClass sysDictClass = new SysDictClass(classNum(YourClass));
SysModel sysModel;
SysModelManifest sysModelManifest;

select Model, Name, Publisher, DisplayName from sysModelManifest
where sysModelManifest.Model == sysDictClass.treeNode().AOTGetModel()
join firstonly Layer from sysModel where sysModel.RecId == sysModelManifest.Model
&& sysModel.Layer == UtilEntryLevel::sys; // Change layer here

if (sysModelManifest)
info(strFmt(“Model: %1”, sysModelManifest.Name));
else
info(“Object is not apart of model in given layer”);

}

Query will fetch Model, its name, Publisher and DisplayName.

Note: Select layer in which you are looking for…

Thanks and Happy DaXing…

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: