Wednesday, April 15, 2020

D365 Color Change by Company

This is for D365 F&O or whatever MS is calling it this year.

It's a pretty traditional request to set the background color of D365 depending on what company (ie legal entity) the user is in.  In D365, the "theme" is a good way to do that.  Normally the theme is set by user in the Settings, User options.  The theme controls the color of the top bar (image below) as well as the color of the accent color throughout D365.


In order to set the users's theme a) when they log on initially and b) whenever they change companies, you need to subscribe to the Info onPostStartup delegate.

To do this, create a new class (naming doesn't matter) and include the code below (just change XYZ to your company).  This is a simplified example, showing the minimum to make this work.  You may not want to hard-code company codes.  And, in case it's not clear, this kind of code would make the theme selection by user, in Settings, User options completely ineffective.  Have fun!


    [SubscribesTo(classStr(Info), delegateStr(Info, onPostStartup))]
    public static void Info_onPostStartup(str startUpCommand)
    {
        if (curExt() == 'XYZ')
        {
            appl.setTheme(SysUserInfoTheme::Theme1);
        }
        else
        {
            //all others
            appl.setTheme(SysUserInfoTheme::Theme3);
        }
    }



Wednesday, January 16, 2019

D365 F&O Create labels quickly

Creating labels in D365 is a step back from AX 2012 because you can't create the label directly from the property or in code.  Yuk.

The only trick that I've found so far is that, in the label file, when you copy (ctrl-c) a highlighted line, you're actually putting the full correct syntax (ie. "@XYZ:EventType", not just "EventType" from example below) in the copy buffer.  That's at least a small help when you go to the property or code to paste.


 Comment if you know of any other time savers.

P.S. I've been using a little clipboard tool to automate my label making while I'm currently creating labels for lots of fields that previously had no labels.  I have the tool automatically remove spaces and some illegal characters.  So, I'll copy the text that is to be made into a label, paste it into both the Label Id and Label fields in the label file, then copy/format/paste the Label Id field to remove all the spaces, then ctrl-s to save the label file line, ctrl-c to load it into the clipboard, and then paste it into the table field label property (or wherever).  That's a convoluted explanation, but you get the concept.  A link to the tool is below:

https://www.donationcoder.com/software/mouser/popular-apps/clipboard-help-and-spell

Wednesday, January 9, 2019

How to Import code XPO to D365 Finance & Operations

The following is a process to use the LCS Code Upgrade tool to import code from AX 4.0 or AX 2009 to D365.

Before you read any further, the key thing here is that you need access to an AX 2012 environment.  You need to use the 2012 environment as a midpoint in the process because only 2012 a) is supported by LCS Code Upgrade tool and b) can import xpo code.  If you don't have access to a 2012 environment, then the following probably won't be helpful to you.

So here's the process:
Prepare the AX 2012 environment
When you use the LCS Code Upgrade tool, you import zip file containing a modelstore.  (not a model!).  If you're like me, you're really only looking to move a subset of customizations...not every last object in your old AX.  The solution here is to use a 'vanilla' 2012 instance.  

There are multiple ways to do this, but I did it by Uninstalling all models except the core sys/syp layer stuff.  LCS Code upgrade will see all the core AX code in your model store, but just ignore it because it's all standard.  

WARNING: Before you uninstall models, make sure you a) have a way to get this code back, b) realize that any data tables defined by uninstalled models (or fields) will be lost.  In my case, I'm using a development environment with no valuable data.  I exported the model store (see procedure below) BEFORE uninstalling any models...and later I'll re-import that model store so I retain all my code.

In 2012 you can see the installed models in Tools, Model management, Installed models

Back up your 2012 code
If you're going to uninstall models from the 2012 environment, you probably want some way to get them all back later.  To 

Uninstall unwanted models
I uninstalled VAR/CUS/USR layer models and all 3rd party (ISV) code.
To uninstall use Windows Powershell (run as Administrator) or AXUtil.  (https://technet.microsoft.com/en-us/hh433514(v=ax.50))
For example:

Now your Installed models should look something like this:

Create a new model in 2012
Create a model with the same name as the model that you intend to use in D365
To do this, in AX 2012: Tools, Modules, Create new model.


Export your code from 4.0 or 2009 in an xpo.

Import your XPO code into 2012
Making sure that you're working in your new model (see lower right of AX screen), import your xpo code from your original environment like you normally would.  The infolog that you get here can be helpful in making sure that you got all the objects that are referenced in the code.  If you missed something, just import it into 2012 - no big deal.

Export the model store
Back in Powershell or AXUtil, export your model store which will contain the sys/syp core code and whatever you imported from your xpo.
For example

The file that is created will be big - maybe 5GB - so make sure you have room on your drive.  But it zips down quite a bit smaller - under 1GB.  The zipped file is what you upload to LCS.

LCS Code Upgrade process
From this point on you'll be following the standard AX2012 -> D365 Code Upgrade process.  Here's a good video overview: https://www.youtube.com/watch?v=M-AtR6ocYM8

One note on what the video covers: Each time you do the Code Upgrade process, you'll see a new folder created under Releases in Azure Dev Ops (or VS Team Explorer, Source Control explorer).  See the 8.1.136.24_U1...folders below.  It was interesting that, while a new 8.1.136.24_U1...folder was created for each Code Upgrade, only a single AX2012 folder was created and it was just updated each time the Cost Upgrade was done.

At first I thought we'd want to use the 8.1.136.24_U1...folder (I'd seen that in doc/videos online), but there were a few issues with that.  In my case the model was prepended by "ApplicationSuite."  Also the 8.1.136.24_U1...folder was missing the XppMetadata folder.  The AX2012 folder, however, had the correct model and included the XppMetadata folder. (Note that the AX2012 folder seems to be overwritten with each run of Code upgrade...so keep that in mind as you decide when to do your merging as discussed below)

So, rather than mapping my VS workspace to one of the 8.1.136.24_U1...folders, I did two merges from the model (ie CompanyNameExtensions) and XppMetadata folders to the corresponding DEV branch locations.   (Notes: In my case the descriptor file that I already had in my dev branch was more accurate, so I didn't merge that.  Also, the Foundation and Update for Foundation folders in my image below can be ignored - they shouldn't be there.  Also, you'll notice that I didn't do anything with the Projects folder because in my case the canned projects that are created by LCS Code upgrade were not helpful.  But you could merge those from the 8.1.136.24_U1...folder to your DEV branch projects folder)


The merges create source-controlled, but not-checked-in objects in the DEV branch and from there you can use VS to build your model and resolve your errors.

Hope that helps!  Have fun!

Monday, March 21, 2016

SSRS Deploy Error - business logic incorrect format


Here's the error on deploy of an SSRS report from AX to the SSRS server:

Make sure that Microsoft Dynamics AX Business Intelligence Components are installed on the SQL Server Reporting machine and verify that SQL Server Reporting Services is configured correctly matching the report server configuration in the Microsoft Dynamics AX client. 
System.Web.Services.Protocols.SoapException: Error while loading code module: ‘xyzShipNotificationReport.BusinessLogic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’. Details: Could not load file or assembly 'xyzShipNotificationReport.BusinessLogic, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
   at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)
   at Microsoft.ReportingServices.WebServer.ReportingService2005.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties, Warning[]& Warnings)

One cause for this error is that the report business logic Visual Studio project is set with a Build Platform target that differs from the SSRS server architecture.  Leaving it at 'Any CPU' is best.

This can happen because when working in the VS project, there is a warning that makes you think that it wants to see 'x86' as the build platform.  If you do that, the warning will go away, but later, when you go to deploy to SSRS, you may get the error above.

The Platform target is set on the Build tab of the project properties:

Thursday, November 5, 2015

SSRS Row Visibility Syntax for NoYes Parameter

For a Dynamics AX NoYesId (checkbox) report parameter that controls Row Visibility (when checked, show row):








...just to save me some experimentation next time.

Wednesday, November 4, 2015

AX 2012 SSRS Report Out of Sync

When something isn't refreshing correctly between AX, VS, and the Report server, follow these steps to get things back in sync.

In this order:
  1. On the Report Server, delete the report
  2. In AX, delete data for report from the SRSReportQuery table (Addins, Table browser) - often skip
  3. In AX, compile forward the DataProvider (DP) class  (Addins, Compile forward)
  4. In VS, refresh the datasets
  5. In VS, save the report to the AOT (use the Add xyzModel to AOT menu, not just save)
  6. In AX, restore the SSRS report object and check it's modified date/time stamp (have to click off/on object)
  7. In AX, clear the caches in the AOT (Tools, Caches)
  8. Restart SSRS service (Administrative Tools, Services: SQL Server Reporting Services)
  9. Close AX client and Restart AOT service (Microsoft Dynamics AX Object Server)
  10. Open AX client and Deploy the report 
  11. Delete AUC and KTI files for user running the report (Users\userName\AppData\Local) - ofthen 

Thursday, July 9, 2015

AX 2012 Courseware Training Materials List

I have  the Microsoft Courseware (training materials) in a big folder, but I don't always remember which 3 character abbreviation matches what I'm looking for.  Well, now I took a few minutes to write it down...

AX 2012
80219_AX2012_ENUS_FINI - Financials I
80220_AX2012_ENUS_FINII - Financials II
80221_AX12_ENUS_IMP - Installation and Configuration
80302_AX2012_ENUS_FA - Fixed Assets
80303_AX2012_ENUS_DEVI - Development I
80304_AX2012_ENUS_DEV_II - Development II
80305_AX2012_ENUS_SCF - Supply Chain Foundation
80306_AX2012_ENUS_DAT - Distribution and Trade
80307_AX2012_ENUS_EPDEV - Enterprise Portal Development
80308_AX2012_ENUS_PROC - Procurement
80309_AX2012_ENUS_PMI - Process Manufacturing Production and Logistics
80310_AX2012_ENUS_LMO - Lean Manufacturing
80311_AX2012_ENUS_SI - Service Industries
80312_AX2012_ENUS_DEVIII - Development III
80313_AX2012_ENUS_DEV_IV - Development IV
80314_AX2012_ENUS_DMB - Discrete Manufacturing Basics
80315_AX2012_ENUS_DMA - Discrete Manufacturing Advanced
80316_AX2012_ENUS_PROJI - Project Essentials
80317_AX2012_ENUS_PROJII - Project Advanced
80318_AX2012_ENUS_REP - Reporting
80338_AX2012_ENUS_PS - Public Sector Financials
80339_AX2012_ENUS_BOM - Bill of Materials
80414_AX2012_ENUS_SMA - Service Management
80415_AX2012_ENUS_PSPP - Public Sector Procurement and Payables
80416_AX2012_ENUS_AIF - Application Integration Framework and Services
80419_AX2012_ENUS_ME - Manufacturing Execution
80421_AX2012_ENUS_SAM - Sales and Marketing
80422_AX2012_ENUS_IC - Intercompany Setup and Order Processing
80423_AX2012_ENUS_MP - Master Planning
80424_AX2012_ENUS_PCF - Product Configuration
80425_AX2012_ENUS_IDMF - Intelligent Data Management Framework
80427_AX2012_ENUS_WM - Warehouse Management
80429_AX2012_ENUS_EXM - Travel and Expense Management
80430_AX2012_ENUS_VMC - Vendor Management and Collaboration

I think my files are from a few years ago (RTM or R2 era)...so there are a few more out there that won't be on this list.  You can log into Customersource or Partnersource for the full list.