Quantcast
Channel: Dynamics Ax – Shashi's Ax.Net Space
Viewing all articles
Browse latest Browse all 57

AX2012 What models have been updated ?

$
0
0

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

Filed under: Ax 2012, Dynamics Ax, SQL

Viewing all articles
Browse latest Browse all 57

Trending Articles