web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Find the layers and models in which a component is present

(0) ShareShare
ReportReport
Posted on by

My requirement is to find the all the layers and their models where a specified component is present. for eg a component 'CustTable' is present in SYS layer Foundation model and also in ISV layer I4C model. Then query should return me the SYS layer and its model Foundation and ISV layer and its model I4C, according to my requirement there must be only 2 records is correct i.e 1st record |SYS | Foundation. 2nd record |ISV| I4C, please help me TIA

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at
    SysModelElement     me;
    SysModelElementData data;
    SysModelManifest    mm;
        
    while select me
        where me.ElementType == UtilElementType::Table
            && me.Name == tableStr(CustTable)
               
            join data
            where data.ModelElement == me.RecId
               
            join mm
            where mm.Model == data.ModelId
    {
        info(mm.Name);
    }
  • Community Member Profile Picture
    on at

    Thanks for the reply Martin, the above query gets the info of only tables, but i need the info of all components tables forms classes etc.. in AOT. Also i need the list of layers and the models in which the component is present. the above code gives info on model. Please help me in getting the info on layers and its models in which a component is present. Thanks in advance.

  • Community Member Profile Picture
    on at

    May be my question was not clear. I think the following would give clear requirement. Find the layers and its models in which a particular component is present. I tried the following sql query

    SELECT met.ElementTypeName

      , ro.Name object

      , me.Name method

      , l.Name Layer

      , mm.Name Model

      , cast([SourceText] as nvarchar(max)) sourceTxt

    FROM [Sources] s

      join ModelElement me on me.ElementHandle=s.SourceHandle

         join ElementTypes met on met.ElementType=me.ElementType

      join ModelElement ro on ro.ElementHandle=me.RootHandle

      left join ModelElementData med on med.ElementHandle=s.SourceHandle and med.LayerId=s.LayerId and med.ElementHandle=me.ElementHandle

      left join Layer l on l.Id=s.LayerId

      left join ModelManifest mm on mm.ModelId=med.ModelId

    where ro.Name like 'InventDim'.

    But the above query gives all the occurances of InventDim component in all layers and models. But i want only to fetch the layers and models in which InventDim component is present. Please help me in solving this.

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Do you mean that you don't know how to modify my example according to your specific requirements, or you just want to me to do your job for you?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Maybe you should tell us why your doing that at all. You might be solving a wrong problem.

  • Community Member Profile Picture
    on at

    Yes I have no idea how to modify the query according to my requirement, would be really helpful if u can send the query for my requirement.

  • Community Member Profile Picture
    on at

    I want to find the layers and models in which a component is present. I would be using this layers and models list in generating xml later using C#. so for this i m connecting to the required database and sending the above query for fetching the layers and models, but i failed todo so. when i tried to check the query result directly on sql server the query returns the all the occurences(where ever this component is used). But according to my requirement i need to get only 2 records since my component is present only in SYS layer-Foundation model and ISV layer-I4C model. How can i achieve this using the above like query.

  • Community Member Profile Picture
    on at

    I failed in writing the correct query please help me in building the right query for my requirement. Thanks in advance.

  • Suggested answer
    dolee Profile Picture
    11,279 on at

    Like this?

    -- Looking up CustTable

    SELECT *

    FROM SYSMODELELEMENT me

    JOIN SYSMODELELEMENTDATA med

    ON me.RECID = med.RECID

    JOIN SYSMODELMANIFEST mm

    ON mm.RECID = med.LAYER

    WHERE me.NAME = 'CustTable'

    AND me.ELEMENTTYPE = '44'

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    What exactly do you mean by "where this component is used" and "where component is present"?

    Can you confirm that my code returns the models you want? If not, what else do you expect?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans