AX2012 What models have been updated ?


While working with Ax 2012 and deploying models, comes a challenge of sending models out.
Probably a challenge only when there tends to be multiple models in the same layer and not all need to be sent out.

Version control knows what I changed

One of the easier ways is to look at Version control and check what has been updated.
That sounds easy? Well what if objects were never checked into version control?
What if you don’t have TFS as a version control (set up on a per model basis)

Model store to the rescue

We know what code has changed -> The Model store holds the data of all the objects in the AOT.
We know when it was changed -> It also holds the Modified date time (And it also holds ModifiedBy, so you can go pursuing the person you are after)
We know what model / layer it is in -> The model jungle holds that data

Ok, How do I get this data now? -> SQL statements.
I have 2 statements which gives the elements that have changed since a certain date, and the other one which groups it all up to say what models have been updated as a high level statement.

SQL Variables (this is where you set the parameters)

DECLARE @DATEMODIFIED nvarchar(100)
DECLARE @ELEMENTTYPESUNWANTED as TABLE (Id int not null)

---Set values here
--Date since when objects have been modified
SET @DATEMODIFIED = '2013-01-24'
--Unwanted Element types
INSERT INTO @ELEMENTTYPESUNWANTED (Id)
values (23), (24) --23: ClassHeader, 24: TableHeader

What elements have been updated?

--List Of elements that have changed--
select L.Name, SYSMM.DISPLAYNAME as 'Model', MED.ModelId,MED.MODIFIEDDATETIME, MED.CREATEDDATETIME, MED.MODIFIEDBY, ME.Name, ET.ElementTypeName, ME.ElementType
from ModelElement ME
join ModelElementData MED on MED.ElementHandle = ME.ElementHandle
join ElementTypes ET on ET.ElementType = ME.ElementType
join SYSMODELMANIFEST SYSMM on SYSMM.MODEL = MED.ModelId
join Layer L on L.Id = MED.LayerId
where MED.MODIFIEDDATETIME >= CONVERT(dateTime, @DATEMODIFIED)
and ME.ElementType not in (select Id from @ELEMENTTYPESUNWANTED)
order by MED.MODIFIEDDATETIME desc

What Models have been updated?

--List of Models That has been updated--
select L.Name, SYSMM.DISPLAYNAME, MED.ModelId
from ModelElement ME
join ModelElementData MED on MED.ElementHandle = ME.ElementHandle
join ElementTypes ET on ET.ElementType = ME.ElementType
join SYSMODELMANIFEST SYSMM on SYSMM.MODEL = MED.ModelId
join Layer L on L.Id = MED.LayerId
where MED.MODIFIEDDATETIME >= CONVERT(dateTime, @DATEMODIFIED)
and ME.ElementType not in (select Id from @ELEMENTTYPESUNWANTED)
group by SYSMM.DISPLAYNAME, MED.ModelId, L.Name
Advertisements

2 thoughts on “AX2012 What models have been updated ?

    1. This is based on “my” Theory on how this is behaving:

      If you change a SYS layer object in the VAR, then there is an entry made in the SYS layer which relates to the classheader if its a class type, and tableHeader if it is a table type. This means the script will report that the SYS layer objects have changed too.

      I hope my theory is right.

      Like

Leave a Reply / Comment

Please log in using one of these methods to post your comment:

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