Thursday, May 11, 2017

Administrating Microsoft Dynamics AX

Administrating Microsoft Dynamics AX


System Administration
·        Manages entire instance of AX

Common
Users – Must be Domain user to manage Users
Register users from Active Directory into Userinfo table
If user is disabled in AD they can’t get into Dynamics AX
You can disable a user in Dynamics by editing their profile and check off Enabled. They can still be active in AD.
Can register AD Groups – Must do manually instead of using Wizard. Any members of the Group are automatically added into AX as a result of belonging to the Group. Assign Roles to the Group and all users within will have that permission.
User Id cannot be more than 8 characters – User Id field is an AX field. If the id is more than 8 characters and first 8 characters match another name it will append numbers to the end of the name to ensure it is unique.  
Security Automation: Can Create Rules in AX to assign Roles to Users based on specific criteria that you select.
Options
Click on Options on Main Menu to view your own profile details, personalization of the screen view, notifications. General User options. Can Edit other users if you have Admin level.
Start Company Account Field  Contoso but this will change when we go to Production. Would never use DAT refers to Demo Data.
Can set User unique Time Zone based on their location.
Document Handling allows you to attach a document to records in AX. Supports only Excel integration with local client, set to Client Excel. Do not want to open Excel on the Server as it will bog down the server. Remote Desktop v6.1 or higher, must have AX integration Tool installed on your local machine.

SQL – Tracing will record all Select statements, Long queries, Warnings and Deadlocks. Use only when trouble-shooting a user issue.
Deadlocks – Don’t use, will not help find deadlocks.
Usage Data – Will show all details of personalization, Click on General Rest and all personalization’s will be removed and views will be set back to Default.
Can setup Microsoft Outlook to integrate with CRM module.

Online Users
Active User shows real active users, other jobs associated with the same user are supportive sessions. Session can be called Worker.
A Deadlock will have a status of Blocking – Can high-light user and click End Session but it will not end until the process is complete. Would need to use SQL statements to end the block and use Stored Procedures. This would require a DBA to complete this step. Someone may call and advise that job is taking too long to run and it usually runs in 30 seconds but is running for 20 min.
User may run End Task, and start another task which will causes a second block. End Users should always call if a job takes too long.
If doing Maintenance, you can select Reject New clients and users will be connected to other AOS service. Users can log out but not be able to log in again.
Axadmin should not be used to do Administration management, it is intended for installation and patch updates, system configuration.
We should be using our own AD account to administrate the Application.
User must be a member of an Active AD Account and AX_Users.
Database Log
Any change to database can be recorded. Don’t go crazy with this tool as it can severely affect performance of the dbase. This is essentially an Audit log of every user’s activities. Try to avoid using Transactional tables, you only want to view Static tables.
CLEAN UP LOGS – Setup a cleanup job that will purge some of the log files that will be generated as a result of turning on Audit, or SQL Trace etc……
Ctrl-G allows you to filter some of the windows.
System Parameters is a Global parameter setting.
Batch Groups – Setup a Batch Group Daily, Weekly, Monthly and assign jobs to the group. Can have more than one Batch server.

  


Periodic - Batch Processing
Batch Groups run same types of jobs via a schedule
Batch processing classes – multiple tasks per job
Client actions are always single-threaded
Can have dependencies so one job runs as a result of completion of prior job
Do not use Alerts with Ended enabled, just use Error or completed.
Runs in specific AOS server
Be careful of heavy system load jobs (MRP) should run at night. Is a collection of tasks – can use multiple threads per server. The server will allocate whatever the job will ask for. Use a performance monitor on the AOS server to indicate performance required along with time to run. This will help to schedule and balance jobs accordingly.
Document all the jobs that are scheduled
Users can run Interactive jobs but would require specific permissions to run in Batch.  Sys-admin is required to schedule Batch jobs.
Reports can run Interactive or Batch – No hard rule as to why a Batch job would run on one AOS server over another. Timing.
Can have as many Groups as you want
Alert job will run as a job in a Batch Group and will run periodically
Need a job to periodically check email queue for Alert notifications – AX configuration piece
Email processing and Alerts need to be setup to be alerted and emailed for AX processes. Both run as Batch processes and scheduled by Sys Admin. Can only send alerts to a specific user, no Groups but can use a dummy account which is actually a Distribution list.
Email Broadcast – Setup an email template and send the message broadcast. Not usually used to notify users. Outlook would be better to notify users. Setup-Email Templates. Can send a pre-defined message to Online Users.
AX can run a consistency check to check referential integrity in the event of a system crash
 System
Client support Options – not needed
System service accounts – not needed (Dan sets up)
Server Configuration – Identifies your Batch Servers available (Dan sets up) threads = maximum number of jobs running at any one time. If you exceed threads all jobs will fill fight for processing power. Do not change Performance Optimization parameters.
Cluster Configuration – Dan sets up (Manual Load balance do not let it auto setup)
Email Parameters – Setup Mail server
Modify Data Types – Do not Touch (Global Changes at all table levels where that data type is found)
Modify Invalid Conditions – Usually used after a migration from previous versions, could be some invalid conditions. Not used often.
Data setup in R3 Sandbox compare to Contoso setup by Microsoft.
WorkFlow – Will be built by Functional Team
Database
Database Log Setup – Alex will provide a list of tables we need to configure in here. Need logging/audit on the tables. Use the Wizard to setup. Recommended.
Tables can be referred by Physical Name or Label – Label is an alias for the table (friendly name). Labels are used to satisfy multiple languages.
Can select specific Table fields to audit – New Transaction (Select), Update, Delete and Rename
When choosing one field to audit you can only select update since Delete would affect the entire record. Stored in logging table in SQL. In the Database Logs table on the Main Page.
If you delete a record you can select re-insert on the Database Log table to put the record back if needed. Be careful if too much time has passed otherwise referential integrity could be compromised with changes made after the delete.
Concurrency Mode – Do not change from Optimistic enabled per table
Licensing Configuration – Do not touch unless working with functional Team
License Information – Identifies Licensed Modules and Feature Sets
If the configuration Key is disabled all associated tables and fields are deleted.
BI
Report Server
Need to define all AOS Servers in order to run reports each AOS
Checklists
Performs updates as per different system options
Enterprise Portal
Cannot update a website, you must drop and delete and register a new one.

Search
Global Search – Alex has a document on how to setup this search feature. Synchronize with the Sharepoint Services.
Can setup database logging for system Administration changes
To port all System Administration changes to another environment
Example: AX2012R3-CFG and AX2012R3_model could be saved and restored to another environment.


On any form in AX you can press Ctrl-P to build a report on the fly

















AX-SQL Tips (Data Backup)

AX-SQL Tips (Data Backup)


Maintenance Plans for Backup
Check Management – Maintenance Plan (Created by Alex)
Back-Up Maintenance Plan – There is a plan in place to do a Full backup of all User Databases including any New databases.
Purge .bak files older than 3 days.
Sp_helpdb will show all the Database backup settings whether Simple or Full.

Shrinking File Sizes
Right Click over Database – Tasks – Shrink – Change from Data to Log – Click ON
Right Click over Database - Click Properties – Click on Files Tab – Check size of File

Stored Procedure – Current Processes
Sp_who2 will show what is running but will not show which user only process owner AXAOS

Blocked Objects
Check the Blk-By column and if anything appears it is locked up. Check further down in this column and see if some other process is locked. Usually more than one lock, kill the offending process.



Microsoft Dynamics 2012 Environment Setup

Infrastructure

The following diagram shows the infrastructure as it is to be deployed on customer sites implementing Dynamics AX 2012. The description for these systems follows below.


Development Environment

The development environment(s) is being used by developers to implement customizations and fix bugs.
A development environment must have all components installed and functional that the targeted production system will have. In most cases, it is best to have these systems completely encapsulated to allow the developer using that system to quickly access all components and eventually modify, restore or remove them without the involvement of a system administrator. This allows for maximum flexibility during the actual development, but requires the developer to maintain it responsibly.
Due to the integration with Team Foundation Server, a development system cannot be easily re-assigned to another developer.
The development environments are the only source of any code that enters TFS. All other systems consume the code stored in TFS.

QA Environment

The QA environment(s) is being used by:
  • Functional consultants to perform the pre-checkin test of customizations.
  • Development Team Leads to perform code reviews.
  • Solution Architects to perform code reviews.
QA environments are usually re-built for the purpose of testing a single customization. The system's live-span is very short and should not be used for any other purpose but testing a single customization.

TFS
The Team Foundation Server (TFS) system hosts the source code control system that stores all customizations, scripts and eventually implementation data.
Users do usually not have access to this system directly. Access to the system is being accomplished through the various front-end components of TFS (e.g. web access, Visual Studio, Dynamics AX).

Build Environment

This environment and system is used exlusively for generating builds out of the version control system and to run the initial test for these generated builds.
The system is being controlled by TFS and only the technical lead would need access to this system for periodic maintenance tasks.

Test Environment

The test environment(s) is being used by users and/or functional consultants to test modifications undisturbed by ongoing development work.
Under no circumstances should developers do development in the test environment.
Debugging in a test environment can be very disruptive to other users and must only be done with prior approval from the project manager for a narrow time window and for issues that cannot be reproduced on the development environment despite multiple attempts to do so.

Training Environment

The training environment is used to train key and end users in preparation for the Dynamics AX 2012 introduction.
The training environment is loaded with builds from the test system that are regarded stable enough to train users on them. The system must not be used to test customizations or other code changes.

Sandbox Environment

Sandbox environments are environments that users and/or developers can play with, modify and test new ideas on without any restrictions. Sandbox environments might be shared. In this case, the users of these systems should be considerate of others that might also be using the system.
Sandbox systems should be periodically re-built. Users of these systems must not assume that changes will be kept or the systems resemble the current build status. Issues and code defects cannot be reported based on a reproduction on a Sandbox system.

Configuration Environment

The configuration system is optional for implementations that have a production systems set up at the beginning of the implementation.
The configuration environment is being used to collect all configuration, parameter and reference data for the implementation. The test if certain data is suitable for the deployment to production must be done on other systems. Under no circumstance should any transactional data be added to this system.
The system is accessible only to users that own data that is being collected on this system. Developers must not have access to this system. If code promotion is being done manually, the Technical Team Lead might require access to promote the latest builds to this system.

Pre-Prod Environment

The Pre-Prod system is used for the final User Acceptance Test and performance tests to be conducted on the system.
Absolutely no code changes or debugging may occur on this system.

Production Environment
Developers should have no access to this system. Exceptions can be made to observe certain system behavior to ease the reproduction of reported issues. In these circumstances, the developer must not be able to change code artifacts of any kind, but might only observe system behavior.
This system must be protected from un-authorized changes (code and data) by all possible means.

Create new Financial Dimension and use on form

Perform Below steps.

a)      Open AOT>>Data Dictionary>>Extended Data Types type/select DimensionDefault and drag it in table which will be used further as a datasource in form where you have to show the Dimensions. Do Remember  that you have to drag it in table not at DataSource.
b)     Open Table in the Data, Dictionary which will be used as a Datasource, and create a realtion with table DimensionAttributeValueSet .
c)      Right Click the Relations. Select ‘New Realation’.  Select properties. Set name as DimensionAttributeValueSet, Table as DimensionAttributeValueSet.
d)     Right Click the this newly created Relation DimensionAttributeValueSet, select New>>Normal.
e)      Set the properties of Normal Realtion as:  Field=TheFieldwhichwillsaveDimensionNumberInYourTable
Source EDT= DimensionDefault
Related Field=RecId

2.      Verify that the table that will hold the foreign key to the DimensionAttributeValueSet table is a
data source on the form(the one on which you have to show dimensions).
3.      Create a tab that will contain the financial dimensions control. This control is often the only
data shown on the tab because the number of financial dimensions can be large.
4.   set properties of Tab as under
a)      Set the Name metadata of the tab to TabFinancialDimensions.
b)     Set the AutoDeclaration metadata of the tab to Yes.
c)      Set the Caption metadata of the tab to @SYS101181 (Financial dimensions).
d)     Set the NeedPermission metadata of the tab to Manual.
e)      Set the HideIfEmpty metadata of the tab to No.
       5.  Override the pageActivated method on the new tab
public void pageActivated()
{
    dimDefaultingController.pageActivated();

    super();
}
      6.   Override the following methods on the form.
class declaration
public class FormRun extends ObjectRun
{
    DimensionDefaultingController dimDefaultingController;
}
init (for the form):
public void init()
{
    super();
    dimDefaultingController=DimensionDefaultingController::constructInTabWithValues(
      true,
      true,
      true,
      0,
      this,
      tabFinancialDimensions,
      "@SYS138487");

    dimDefaultingController.parmAttributeValueSetDataSource(myTable_ds,
    fieldstr(myTable, DefaultingDimension));
}
    7.      Override the following methods on the form data source
            public int active()
{
    int ret;
    ret = super();
    dimDefaultingController.activated();
    return ret;
}
public void write()
{
    dimDefaultingController.writing();
    super();
}
public void delete()
{
   
    super();
  dimDefaultingController.deleted();
}



Wednesday, April 5, 2017

SQL Database Restore Query

USE [master]
ALTER DATABASE [DB Name] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

RESTORE DATABASE DB Name FROM  DISK = N'\\File Path' WITH  FILE = 1
,  NOUNLOAD,  REPLACE,  STATS = 5

ALTER DATABASE DB Name SET MULTI_USER

GO

Monday, March 13, 2017

Get currnt company name in SSRS reports

=Microsoft.Dynamics.Framework.Reports.DataMethodUtility.
GetFullCompanyNameForUser(
Parameters!AX_CompanyName.Value,Parameters!AX_UserContext.Value)

Saturday, March 11, 2017

Serial Number in SSRS ( Normal and with Group)

we can get the sequence number directly in SSRS report directly by below code in text box expression. it's basically depends on row number so you can get it from expression -   Common Function -Miscellaneous - row Number.

=RowNumber(Nothing)

The challange to use this expression is when we will use grouping in same table. Sequesnce of the number can be disturb by grouping. We can handle it by below code.

=Runningvalue(Fields!Name.value,countdistinct,"Dataset1")

** Here field name is the actual field which we are using in grouping with database name.

Wednesday, March 1, 2017

Wednesday, February 8, 2017

Query not taking BackSlash " \ " value in AX

As AX doesn't support back slash value "\" value in X++ code but allows the same value in data base field value (In Table Field value) , So some time it's hard to get the expected value in query . I had the same problem which i got by below solution.

Problem : -

 LedgerJournalTrans hold a value with back slash (MP\PV16\000014). When i was getting the value in query to pass it in a range it was removing "\" Automatically which was the case of data mismatch and value was not coming from table. Our report was showing blank data in report.

Solution:-  

Query doesn't recognize single back slash. so we use to use double back slash "\\" to define a single slash in a value. If we are getting a from any table then we have to convert single slash in to double slash. For that we have to type four slash "\\\\".

voucher     = strReplace(contract.parmVoucher(),"\\","\\\\");

here our value (MP\PV16\000014)contain single slash  which we are replacing with double slash by four time slash. 

Tuesday, February 7, 2017

AX 2012 - Understanding AOT Maps with an example

Background

Maps are not new concept in software development actually. They are table wrappers to achieve general behavior. However for lame dude(s) like me, these definition words have not been enough.

Problem

The term allotted to Maps, "Map" itself is a bit confusing. But an example can really help understanding. And Maps are used everywhere, but in comparison to tables and classes ( see these building blocks are essential for any kind of most basic development), use of maps are quite rare.

Example

I have been browsing PurchTableHistory table. A method came into my consideration where I see the use of Map.  

The method, PurchTableHistory[T] >> initFromPurchTable() declares several maps based on localized buffers. Look at the following code

// Code example
PurchTableMap purchTableMap;
purchTableMap.data(_purchTable.data());
this.data(purchTableMap.data());
First, the row from PurchTable is copied to the map variable, 'purchTableMap', and then, the history buffer gets the same row but form map, and not from the original source, purchTable buffer

WHY ? Their must be a genuine need ? Why don't we copy from the original PurchTable buffer  ? Becuase we cannot :) becuase of schema change. See if most of the fields are same but not with exact field names, types and filed list count, we cannot copy a row from one table to another using xRecord[C].data() simply because of schema mismatch.

Here is where map can work, since the different name same type and purpose fields are MAPPED in the MAP :). Fields with different names from different tables are mapped to consistent names in map, so that you can use them to map one row ( from one table buffer) to another table.

One more thing, when using maps, field count doesn't matter since the map will only care and execute on the schema defined in the map. It simply would not care for schema defined in the mapped tables, it would only care for the schema defined in the MAP

Wednesday, February 1, 2017

How to find or create default Dimension from X++ in AX 2012


This is static method to find or create default dimension:

static DimensionDefault createDefaultDimension(container _attr, container _value, boolean _createIfNotFound = true)
{
    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                               result;
    int                                                      i;                            
    DimensionAttribute                            dimensionAttribute;
    DimensionAttributeValue                   dimensionAttributeValue;
    //_attr is dimension name in table DimensionAttribute
    container               conAttr =   _attr;
    container               conValue = _value;
    str                     dimValue;

    for (i = 1; i <= conLen(conAttr); i++)
    {
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

        if (dimensionAttribute.RecId == 0)
        {
            continue;
        }

        dimValue = conPeek(conValue,i);

        if (dimValue != "")
        {
            // _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.
            dimensionAttributeValue
                    dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,_createIfNotFound);

            // Add the dimensionAttibuteValue to the default dimension
            valueSetStorage.addItem(dimensionAttributeValue);
        }
    }
    result = valueSetStorage.save();
    return result;
}

Conversion of Disposition code, code was not specified - Error in D365 F&O for inter company purchase order return

 We crated the return order for inter company purchase order  and created a Item Arrival Journal through Arrival Overview in corresponding c...