Wednesday, April 25, 2018

Financial Dimensions....Pesky Financial Dimensions

Finally...in code, how to retrieve a dimension value from a default dimension and a dimension name:

public str getDimensionValueByName(DimensionDefault _dimension, str _dimensionName)
{
    DimensionAttributeValueSetStorage dimStorage;
    Counter i;
    str result;
   
    dimStorage = DimensionAttributeValueSetStorage::find(_dimension);
    for(i = 1; i <= dimStorage.elements(); i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == _dimensionName)
        {
            result = dimStorage.getDisplayValueByIndex(i);
            break;
        }
    }
   
    return result;
}

How to get or create a default dimension:

public DimensionDefault getOrSetDefaultDimension()
{
    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault result;
 
    int i;
    DimensionAttribute dimensionAttribute;
    DimensionAttributeValue dimensionAttributeValue;
    str dimValue;  
 
    container conAttr = [d1Name, d2Name, d3Name];
    container conValue = [d1Value, d2Value, d3Value];
 
    for (i = 1; i <= conLen(conAttr); i++)
    {            
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));
     
        if (dimensionAttribute.RecId == 0)
        {
            continue;
        }
     
        dimValue = conPeek(conValue,i);
     
        if (dimValue != "")
        {
            // The last parameter is "true". A dimensionAttributeValue record will be created if not found.
            dimensionAttributeValue =
                    dimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,dimValue,false,true);
         
            // Add the dimensionAttibuteValue to the default dimension
            valueSetStorage.addItem(dimensionAttributeValue);
        }            
    }    
 
    result = valueSetStorage.save();
    return result;
}

Thursday, January 4, 2018

D365 - Security Fix Crashes SQL Server 2016

Happy New Year.

Yesterday, I get a call from the project team.  Apparently, they found a bug that needs an emergency fix.  This was a project that I haven't looked at in over a month.  Starting my VM, I found out that my SQL Server Instance was crashing.  The message that I kept getting was:

FCB::Open failed: C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn\mssqlsystemresource.mdf
   1
   2(The system cannot find the file specified.)

My initial check indicated that that was a security issue that my logon user for my SQL Instance needed to granted access to the relevant directories.  However, my user was Network Service, so it should have full permissions for everything on the VM.

Further checking indicated that a security patch from MS was to blame.  Apparently, the files (both mdf and ldf) were moved to different location: C:\Program Files\Microsoft SQL Server\130\LocalDB\Binn.  Copying and pasting the files to the correct location solved the problem.

http://strictlysql.blogspot.ca/2016/11/sql-server-2016-sql-service-doesnt.html

Tuesday, December 12, 2017

IIS Compatibility Issues

Innocently working along in a small ASP.Net project (first time in a couple of years), a client noticed that a text area was displaying too thinly (about 50 pixels wide) when it was supposed to cover the full width of a tab page.  After checking around, I found that it was probably to compatibility mode in her IE11 settings.  Setting a meta tag to for IE9 compatibility solved the issue.

https://serverfault.com/questions/142721/iis-displaying-page-differently-when-localhost-is-used-in-url-vs-hostname
https://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
https://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx

Monday, November 27, 2017

Allowing IIS Application Pools to Access Local Folders

I was working recently with a client's ASP.Net application and had a requirement to log various items to a file log.  One of the issues was how to grant the correct user read/write permissions to folder in question.  This article explains how to grant folder permissions to the user running a given application pool.

https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities

Essentially, it involves granting "IIS AppPool\DefaultAppPool" or other application pool name (as defined in IIS) the appropriate permission.

Friday, November 17, 2017

D365 - Windows Server 2016 Datacenter Re-Activation

The Windows edition on my VM for client development expired.  It then started shutting down every 1/2 hour.  Needless to say this is quite annoying.

After some googling, I found that the evaluation edition of Windows can be re-armed.  The command to do this in the command prompt is:

slmgr.vbs -dli

If that doesn't work, try:
slmgr.vbs -rearm

https://organicax.com/2014/10/03/windows-rearm
https://support.microsoft.com/en-us/help/948472/how-to-extend-the-windows-server-2008-evaluation-period

The articles say that the extension is 60 days,  however my VM says 180.

Thursday, October 26, 2017

Decrypt Web.Config for D365

If you need to get into a D365 database that is located on a D365 VM.  The credentials are located under <install drive>:\aosservice\\webroot.  However, they are encrypted.  To decrypt them, you just need to run the following in a console window:

<install drive>::\AOSService\webroot\bin\Microsoft.Dynamics.AX.Framework.ConfigEncryptor.exe -decrypt <install drive>::\AOSService\webroot\web.config

Just make sure that you open the console as an administrator.  Normal users do not have access to the RSA keys.

Monday, October 2, 2017

Note to self...

Do not define string EDTs with length of 4000 characters.  Ax uses Unicode, so 2000 characters is 4000 bytes.  As a result, inserts will generate an Invalid Precision Value error in SQL Server.  Use a memo type instead.

https://community.dynamics.com/ax/f/33/t/177918