Friday, November 3, 2017

How to add a new operating unit type

For AX2012, you can follow the steps in this link https://msdn.microsoft.com/en-us/library/gg989762.aspx
Couple of important points:

  1. The new enum value must use the immediate next number for that enum (you should not skip any number)
  2. The new enum name drives the view name that you need to create. AX will look for a view with "DimAttribute" prefix after the enumeration name.
    For example, if the new enum name is OMBranch then the view name must be DimAttributeOMBranch.

For D365, it is quite similar to the steps in AX2012, however in the view it should have a method called registerDimensionEnabledTypeIdentifier and you should use the view name that you just created. This will then add the new operating unit as a dimension type.

Keep in mind that in D365, there are 3 additional operating unit types (branch, rental location, region) that are part of the Fleet Management model, which is actually a sample model and doesn't get installed by default to tier 2 or production environments.

Wednesday, November 1, 2017

Management Reporter scripts

Few scripts that can be used to check the MR integration tasks:

Check all integration tasks that have been executed:

--List details about each DDM task: state, progress, last...
--List details about each DDM task: state, progress, last/next runtime in local time, and the interval that each runs 
--Status 5=Success; 3=Running; 6=Cancelled
select CIG.[Description] 
, STK.[Name] 
, STS.[Progress] 
, CASE STS.[StateType]  
WHEN 3 THEN 'Processing' 
WHEN 5 THEN 'Complete' 
WHEN 7 THEN 'Error' 
END AS StateType
, DATEADD(minute, DATEDIFF(minute,GETUTCDATE(),GETDATE()), STS.[LastRunTime]) as LocalLastRunTime 
, DATEADD(minute, DATEDIFF(minute,GETUTCDATE(),GETDATE()), STS.[NextRunTime]) as LocalNextRunTime 
, CM.[ContinueOnRecordError] 
, STRG.[Interval] 
, CASE STRG.[UnitOfMeasure] 
WHEN 2 THEN 'Minutes' 
ELSE 'Seconds' 
END AS IntervalTiming
, CASE STRG.[IsEnabled] 
WHEN 1 THEN 'Enabled' 
ELSE 'Disabled' 
END AS NameStatus
from [Connector].[Map] CM with (nolock) 
inner join [Scheduling].[Task] STK with (nolock) on STK.[Id] = CM.[MapId] 
inner join [Scheduling].[TaskState] STS with (nolock) on STK.[Id] = STS.[TaskId] 
inner join [Connector].[IntegrationGroup] CIG with (nolock) on CIG.[IntegrationId] = STK.[CategoryId] 
inner join [Scheduling].[Trigger] STRG with (nolock) on STK.[TriggerId] = STRG.[Id] 
order by CIG.[Description], STK.[Name]


Check the tasks outcomes

select CIG.[Description], ST.[Name], SM.[Text], 
DATEADD(minute, DATEDIFF(minute,GETUTCDATE(),GETDATE()), SL.[StartTime]) as LocalStartTime, 
DATEADD(minute, DATEDIFF(minute,GETUTCDATE(),GETDATE()), SL.[EndTime]) as LocalEndTime, 
SL.[TotalRetryNumber], SL.[IsFailed], STT.[Name] as TaskType 
from [Scheduling].[Log] SL with (nolock) 
inner join [Scheduling].[Task] ST with (nolock) on SL.TaskId = ST.Id 
inner join [Scheduling].[Message] SM with (nolock) on SL.Id = SM.LogId 
inner join [Scheduling].[TaskType] STT with (nolock) on ST.TypeId = STT.Id 
inner join [Connector].[IntegrationGroup] CIG with (nolock) on CIG.[IntegrationId] = ST.[CategoryId] 
order by SL.[StartTime] desc


Check the current integration activities

SELECT sqltext.TEXT, 
req.session_id, 
req.status, 
req.command, 
req.cpu_time, 
req.total_elapsed_time 
FROM sys.dm_exec_requests req 
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS sqltext