Friday, November 13, 2015

No response when creating planned production order

Last time, my colleague try to create planned production order manually. However, system has no response when the create button clicked.


After tracing X++ code, I found that it calls Method flushCommands of Class WrkCtrSchedulerJobSchedulingEngine. In this method, it will catch CLRError.
To avoid this error, option "Enable the hot-swapping of assemblies for each development session" should not be checked in Microsoft Dynamics AX Server Configuration.


After I un-check this option, planned production order can create manually.

Tuesday, October 20, 2015

AX2012 R2 Get a list of Duties and Privileges based on Security Role

This is a SQL script to get a list of duties and privileges based on a security role.
  
USE [Model_database_name];
 
SELECT secRole.AOTNAME [Role_Name], secRoleExplode.SECURITYROLE, 
secRole2.AOTNAME [Subrole_Name], secRoleExplode.SECURITYSUBROLE, 
secTask.AOTNAME [Task_name], secRoleTask.SECURITYTASK, 
secTask2.AOTNAME [secTask2_name], secTaskExplode.SECURITYSUBTASK,
CASE
  WHEN secTask2.TYPE = 0 THEN 'Privilege'
  WHEN secTask2.TYPE = 1 THEN 'Duties'
  ELSE 'Other'
END AS OBJECTTYPE
--,secTaskEntryPoint.ENTRYPOINT, secObject.name, 
--CASE
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 0 THEN 'No access'
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 1 THEN 'Read'
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 2 THEN 'Update'
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 3 THEN 'Create'
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 4 THEN 'Correct'
--  WHEN secTaskEntryPoint.PERMISSIONGROUP = 5 THEN 'Delete'
--END AS [Access level], secObject.TYPE
FROM SECURITYROLE secRole
join SECURITYROLEEXPLODEDGRAPH secRoleExplode
ON secRole.RECID = secRoleExplode.SECURITYROLE
JOIN SECURITYROLE secRole2
ON secRoleExplode.SECURITYSUBROLE = secRole2.RECID
JOIN SECURITYROLETASKGRANT secRoleTask
ON secRoleExplode.SECURITYSUBROLE = secRoleTask.SECURITYROLE
JOIN SECURITYTASK secTask
ON secTask.RECID = secRoleTask.SECURITYTASK
JOIN SECURITYTASKEXPLODEDGRAPH secTaskExplode
ON secRoleTask.SECURITYTASK = secTaskExplode.SECURITYTASK
JOIN SECURITYTASK secTask2
ON secTaskExplode.SECURITYSUBTASK = secTask2.RECID
--JOIN SECURITYTASKENTRYPOINT secTaskEntryPoint
--ON secTaskEntryPoint.SECURITYTASK = secTask2.RECID
--JOIN SECURABLEOBJECT secObject
--ON secObject.RECID = secTaskEntryPoint.ENTRYPOINT
WHERE secRole.AOTNAME = 'HcmEmployee'
ORDER BY OBJECTTYPE, secRoleExplode.SECURITYSUBROLE

Friday, March 28, 2014

Custom Lookup in Enterprise Portal

We can using AX query to build the custom lookup function in Enterprise Portal. Here is a example on Expense type in Expense Report.
  
protected void CostType_Lookup(object sender, AxLookupEventArgs e)
    {
        AxLookup lookup = e.LookupControl;

        using (Proxy.SysDataSetBuilder sysDataSetBuilder =
            Proxy.SysDataSetBuilder.constructLookupDataSet(
                this.AxSession.AxaptaAdapter, TableMetadata.TableNum("TrvCostType")))
        {
            lookup.LookupDataSet = new DataSet(this.AxSession, sysDataSetBuilder.toDataSet());
        }

        using (Proxy.Query query = lookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
        {
            Proxy.QueryBuildRange categoryRange = query.dataSourceNo(1).addRange(TableDataFieldMetadata.FieldNum("TrvCostType", "IsInactive"));
            categoryRange.value = "0";
            categoryRange.status = (int)Proxy.RangeStatus.Hidden;
        }

        AxBoundField costTypeBoundField = AxBoundFieldFactory.Create(lookup.LookupDataSetViewMetadata.ViewFields["CostType"]);
        costTypeBoundField.SortExpression = "CostType";
        lookup.Fields.Add(costTypeBoundField);

        AxBoundField costTxtDateBoundField = AxBoundFieldFactory.Create(lookup.LookupDataSetViewMetadata.ViewFields["CostTxt"]);
        costTxtDateBoundField.SortExpression = "CostTxt";
        lookup.Fields.Add(costTxtDateBoundField);

        lookup.SelectField = "CostType";
    }


And also, we have to call the lookup method in Web Control.
 


Friday, October 11, 2013

Get FormRun object and FormDataSource from ListPageInteraction class

When we are working on List Page objects in Dynamics AX 2012, we found that methods cannot be added/modified in list page form. We have to work on the corresponding ListPageInteraction class.

Most of the time, we have to get the FormRun object and FormDataSource for different event inside the list page, the following coding can help to get these object form ListPageInteraction class.
  
    ListPage listPage = this.ListPage();
    Common common = listPage.activeRecord([DataSourceName]);
    FormDataSource fds;

    if (common.isFromDataSource())
    {
        fds = common.dataSource();
        fds.formRun().control(fds.formRun().controlId([FormControlName])).userPromptText('New Description');
    }

Multi-selection on form grid handling: MultiSelectionHelper

In Dynamics AX 2012, a new class "MultiSelectionHelper" will handle those heavy lifting task for you as the following.

    Common common;
    MultiSelectionHelper helper = MultiSelectionHelper::construct();
    
    helper.parmDatasource(formDataSource);

    common = helper.getFirst();
    while (common.RecId != 0)
    {
        ...

        common = helper.getNext();
    }

Friday, October 4, 2013

Installing App Fabric on Windows Server 2012 for SharePoint 2013 giving error

While installing Windows Server App Fabric of pre-requisites software for SharePoint 2013, the following error generated in log file and error code 1603 is returned.
 
10-04 11:45:15, Information           Setup  Process.Start: C:\Windows\system32\msiexec.exe /quiet /norestart /i "c:\e435f7e3b63e889120d837c913\Packages\AppFabric-1.1-for-Windows-Server-64.msi" ADDDEFAULT=Worker,WorkerAdmin,CacheService,CacheClient,CacheAdmin,Setup /l*vx "C:\Users\Administrator\AppData\Local\Temp\AppServerSetup1_1(2013-10-04 11-45-15).log" LOGFILE="C:\Users\Administrator\AppData\Local\Temp\AppServerSetup1_1_CustomActions(2013-10-04 11-45-15).log" INSTALLDIR="C:\Program Files\AppFabric 1.1 for Windows Server" LANGID=en-US
2013-10-04 11:45:53, Information           Setup  Process.ExitCode: 0x00000643
2013-10-04 11:45:53, Error                 Setup  AppFabric installation failed because installer MSI returned with error code : 1603
2013-10-04 11:45:53, Error                 Setup  
2013-10-04 11:45:53, Error                 Setup  AppFabric installation failed because installer MSI returned with error code : 1603
2013-10-04 11:45:53, Error                 Setup  
2013-10-04 11:45:53, Information           Setup  Microsoft.ApplicationServer.Setup.Core.SetupException: AppFabric installation failed because installer MSI returned with error code : 1603
2013-10-04 11:45:53, Information           Setup     at Microsoft.ApplicationServer.Setup.Installer.WindowsInstallerProxy.GenerateAndThrowSetupException(Int32 exitCode, LogEventSource logEventSource)
2013-10-04 11:45:53, Information           Setup     at Microsoft.ApplicationServer.Setup.Installer.WindowsInstallerProxy.Invoke(LogEventSource logEventSource, InstallMode installMode, String packageIdentity, List`1 updateList, List`1 customArguments)
2013-10-04 11:45:53, Information           Setup     at Microsoft.ApplicationServer.Setup.Installer.MsiInstaller.InstallSelectedFeatures()
2013-10-04 11:45:53, Information           Setup     at Microsoft.ApplicationServer.Setup.Installer.MsiInstaller.Install()
2013-10-04 11:45:53, Information           Setup     at Microsoft.ApplicationServer.Setup.Client.ProgressPage.StartAction()

It would be caused by incorrect PSModulePath in Environment Variable which having a trailing double quote ("), which broke any scripts that used the PSModulePath variable.