Tuesday, December 13, 2011

DAX Dude: AX 2009 Batch Job Stuck In Executing

DAX Dude: AX 2009 Batch Job Stuck In Executing:

'via Blog this'

Monday, December 12, 2011

Wai Keat Ng's Dynamics AX Blog: Create Alert using X++ codes

Wai Keat Ng's Dynamics AX Blog: Create Alert using X++ codes: "EventInbox inbox;
;

inbox.initValue();
inbox.ShowPopup = NoYes::Yes;
inbox.Subject = "This is the Alert subject";
inbox.Message = "This is the Alert message";
inbox.AlertedFor = "This alert is just information no links are available";
inbox.SendEmail = false;
inbox.UserId = curuserid();
inbox.TypeId = classnum(EventType);

inbox.AlertTableId = tablenum(Address);
inbox.AlertFieldId = fieldnum(Address, Name);
inbox.TypeTrigger = EventTypeTrigger::FieldChanged;
inbox.CompanyId = curext();
inbox.InboxId = EventInbox::nextEventId();;
inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
inbox.insert();"

'via Blog this'

Dynamics AX Custom ALerts

Query :

How can i add custom alerts in dynamics ax?

Answer :


void createAction()
{


    EventNotificationSource _source;
    EventNotificationBatch event =    EventNotification::construct(EventNotificationSource::Batch);
    ;


        event.parmUserId(curuserid());
        event.parmSubject(subject);
        event.parmMessage(message);
        event.parmNotificationType(EventNotificationType::Action);
        event.parmShowPopup(NoYes::Yes);
        event.parmSendEmail(sendemail);
        event.create();
}

Sunday, November 20, 2011

Dynamics AX 2009 + SSRS Lessons Learned

Following are the lessons i have learned when configuring SSRS for AX 2009,

1- Always use IP address for connecting to SSRS
2- Add both the business connector user and the client connecting user as AX users, for instance if your bc user is proxy and the client connecting is newclient both the ID's should be in AX.
3- Make sure the business connector is configured properly.
4 -Make sure that SSRS URL is under trusted sites.

Tuesday, November 15, 2011

app.config editor

Question:


Is there any application around which I can use to update app.config files associated with .Net applications.


Answer:


The best application I have found is hosted on code project, http://www.codeproject.com/KB/files/AppConigEditor.aspx

Wednesday, November 9, 2011

Dynamics AX 2009 Known Issues

Question  :


Is there a place to review all the knows Dynamics AX 2009 Issues ?


Answer:


Yes, kindly review the following link.
http://dynamicspost.blogspot.com/2011/04/ax-2009-known-issues-solutions.html

Tuesday, November 8, 2011

RPC 5 Exception

Question :
I am running SSRS 2008 R2 with Dynamics ax under network services user. Issue is sometimes the reports show up and sometimes they do not. I notice that i have few error with RPC 5 exception in my event log.

Answer :
This is a know issue. To fix this for SSRS 2008 remove the execution account from SSRS configuration manager and run the SSRS service under BC Proxy account. 

Dynamics AX SSRS The request failed with HTTP status 401

Question : 
I am receiving a 401 error when connecting to AX Reports hosted on SSRS 2008 R2.


Answer :
The solution that worked for me was to open rsreportserver.config file placed in the reporting services instalaltion directory, finding authentication group and commenting WindowsNegotiate tag as shown below.

 
   
   
 
  true

Monday, October 24, 2011

Dynamics AX Log On Failed on Reporting Services

Query:

I am getting a logon failure when running reporting services for dynamics.

Answer:

Make sure the business connector credentials are correct.

Sunday, October 23, 2011

Seconds to actual time in C#

I always used to have issues when debugging time related issues in AX. Time is saved in seconds so many time when you want to know the actual time associated with it in hh : mm :  ss, you will either have to do it in mind or use a calculator. In order to simplify debugging I have created a small C# based console application that takes seconds as input and returns the time in actual format.

The code is below and you can compile it in visual studio to make it work.

Enjoy!

Download the application from here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Decimal2Hours
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine(Program.ConvertSecondsToHoursMinutes(Console.ReadLine()));
            }
        }


        public static string ConvertDecimalToHours(string paramHours)
        {
            int realPart;
            int decimalPart;
            decimal hours;
            string hoursStr;
            string minStr;
            int decimalLocation;
            string finalMinutes;
            decimal _hours = decimal.Parse(paramHours);
            ;
            try
            {
                hours = _hours;
                hoursStr = hours.ToString();
                decimalLocation = hoursStr.IndexOf(".");
                hoursStr = hoursStr.Substring(0, decimalLocation);
                hoursStr = hoursStr.Trim(new char[] { '.' });
                minStr = hours.ToString();
                minStr = minStr.Substring(decimalLocation);
                minStr = minStr.Trim(new char[] { '.' });
                realPart = Convert.ToInt32(hoursStr);
                decimalPart = Convert.ToInt32(Math.Floor((decimal)Convert.ToDecimal("0." + minStr) * 60));
                finalMinutes = (realPart.ToString().Length == 1 ? "0" + realPart.ToString() : realPart.ToString())
                                + ":" +
                                (decimalPart.ToString().Length == 1 ? "0" + decimalPart.ToString() : decimalPart.ToString());
                return finalMinutes;
            }
            catch
            {
                return paramHours;
            }
        }


        public static string ConvertSecondsToHoursMinutes(string paramSeconds)
        {
            string finalTime;
            int seconds = Convert.ToInt32(paramSeconds);
            int result;
            int hours = Math.DivRem(seconds, 60 * 60, out result);
            seconds = result;
            int minutes = Math.DivRem(seconds, 60, out result);
            seconds = result;


            finalTime = hours.ToString() + " : " + minutes.ToString() + " : " + seconds.ToString();


            return finalTime;
        }
    }
}

Monday, October 17, 2011

Dynamics AX Excel Sheet Import, In Correct Time Values

Query
Whenever I import an excel sheet containing a timing point, it is converted to 1 second less than the actual value. 


Answer
This is a known issue and you can look at http://support.microsoft.com/kb/969186 for the resolution and workaround. 

Wednesday, October 12, 2011

SharePoint Database Configuration Failed

Query :


I changed the DNS IP today and was unable to connect to SharePoint database. The error that i am getting is "Failed to connect to the configuration database"


Answer :
There can be many factors to cause this issue. You can read about this issue at "http://support.microsoft.com/kb/823287/en-us". 


One more issue can be the change of the IP of your DNS Server. In order to resolve most of the issues you can create a new database using the following command,


  "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\PSCONFIG.EXE" -cmd configdb -create -database

Tuesday, August 23, 2011

Excel Value to String

Query: How can i create a generic method for returning string values from excel.

Answer:

// convert into str from excel cell value
str COMVariant2Str(COMVariant _cv,
                    int _decimals = 0,
                        int _characters = 0,
                        int _separator1 = 0,
                        int _separator2 = 0)
{
    switch (_cv.variantType())
    {
        case (COMVariantType::VT_BSTR):
            return _cv.bStr();

        case (COMVariantType::VT_R4):
            return num2str(_cv.float(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_R8):
            return num2str(_cv.double(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_DECIMAL):
            return num2str(_cv.decimal(),_characters,_decimals,_separator1,_separator2);

        case (COMVariantType::VT_DATE):
            return date2str(_cv.date(),123,2,1,2,1,4);

        case (COMVariantType::VT_EMPTY):
            return "";

        default:
            throw error(strfmt("@SYS26908", _cv.variantType()));
    }
    return "";
}

Wednesday, August 17, 2011

Corrupted applicationHost.config

Query:
The IIS file applicationHost.config got corrupted today, is there any way i can regenerate?

Answer:
You can restore from the backup placed at C:\inetpub\history

Monday, August 15, 2011

ssrs unable to load client print control on windows 2003

Query:
I am getting an issue when trying to print the SSRS reports. It keeps saying "unable to load client print control".


Answer:

Uninstall KB KB956390

Sunday, July 24, 2011

Dynamics AX Workflow Purchase Requistion

Queries:
I can not create purchase requisition on behalf of other users?

Answer:
Go to HR->Employee Details->Setup->on behalf of to setup employees on behalf of whom you want to create PR's.

Thursday, July 21, 2011

How to check configuration key in X++

Query:
How can i check if the configuration key is enabled through x++?

Answer:
if (isConfigurationKeyEnabled(configurationkeynum(keyname)))
{
//insert code here
}

Sunday, July 17, 2011

SSRS Deployment Issue "Not Found"

Query:
I am getting a "Not Found" issue when deploying SSRS components.

Answer:
Install KB957312.

Sunday, July 10, 2011

Sunday, June 26, 2011

Call webservice using SQL Server

Query:
How can I call an AIF service using SQL Server 2008?

Answer:
You can use http://technet.microsoft.com/en-us/sqlserver/ff686773.aspx to see how it is done.

Wednesday, June 22, 2011

Dynamics AX Run Time Dialog

Query:
Can I create a dialog on run time?

Answer:
Use the following class
///

///  This is a class to create dynamic dialog on the fly
///

///
/// Usage
/*
static void testDynamicDialog(Args _args)
{
  CustomDialog   diag;
  List           types = new List(Types::Integer); // typeId is an integer
  List           fields;
  ListEnumerator enum;
  DialogField    field;
  ;

  // the dialog shall contain fields for the following types
  types.addEnd(typeId(EmplId));
  types.addEnd(typeId(Itemid));
  types.addEnd(typeId(ProdId));
  types.addEnd(typeId(CustAccount));

  // crate and show
  diag = new CustomDialog(types,"Dynamic Dialog");
  diag.run();

  // show values in the Infolog
  fields = diag.parmFieldList();
  enum   = fields.getEnumerator();

  while(enum.moveNext())
  {
    field = enum.current();
    info(field.value());
  }
} */
///


class MSTACustomDialog extends Dialog
{
    List fieldList;
}


public List parmFieldList()
{
    return fieldList;
}

void new(List typeList, Caption _caption = '', Object _caller = null, str _parmstr = '', Form _form = new Form(formStr(Dialog)))
{
    ListEnumerator enum;
    ;

    if(typeList == null)
      error("@BCS3969");

    super(_caption, _caller, _parmStr, _form);

    fieldList = new List(Types::Class);
    enum      = typeList.getEnumerator();

    while(enum.moveNext())
    {
      fieldList.addEnd(this.addField(enum.current()));
    }
}

Monday, June 13, 2011

Reading CSV File in AX

Query:
How can I read a csv file in AX?

Answer:
use the following code,

public void run()
{
    #File
    CommaTextIo commaTextIo;
    FileIOPermission permission;
    container containFromRead;
    int x;
    int cols;
    PurchIdBase purchId;
    LineNum lineNum;
    ;
    super();
    if(!this.validate())
    {
        return;
    }


    try
    {
       
        permission = new FileIOPermission(filePath, #io_read);
        permission.assert();


        commaTextIo = new CommaTextIO(filePath, #io_read);
        containFromRead = commaTextIo.read();


        while(containFromRead)
        {
            cols = conLen(containFromRead);
            for(x=1; x <= cols; x++)
            {
                info(any2str(conpeek(containFromRead, x)));
            }
            containFromRead = commaTextIo.read();
        }
        commaTextIo = null;
    }
    catch(Exception::Error)
    {


    }
}

CommaTextIO not initialized error

Query:

I am getting commatextio not initialized error and it is not going away. I am sure my code is right.

Answer:

Make sure you are on the correct tier (client or server) and make sure you have permission on that file for the specific tier.

Hint: see the main and construct methods make sure they don't have only server keyword.

Wednesday, June 8, 2011

Passing arguments between two forms

Query:
How can I pass information from 1 form to another?

Answer:
IN the clicked button of form A write following code,
void clicked()
{
    Args args;
    FormRun formRun;
    ;
    super();

    args = new Args(formstr(FormName));
    args.parm(parameters);
    formRun = classFactory.FormRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
    formRun.detach();
    parenttable_ds.refresh(); // Refreshing parent table DataSourceTable
    parenttable_ds.executeQuery(); // Refreshing Parent DataSourceTable Query
}

IN form B init method write following code
args = element.args();
args.parm()

Sunday, June 5, 2011

Converting Real Number to TIme

public static str 5 num2Time(real _hours)
{

    int realPart;
    int decimalPart;
    real hours;
    str hoursStr;
    str minStr;
    int decimalLocation;
    str finalMinutes;
    ;
    try
    {
        hours = _hours;
        hoursStr = num2str(hours, 0, 2, 1, 0);
        decimalLocation = strfind(hoursStr, ".", 0, strlen(hoursStr));
        hoursStr = substr(hoursStr, 0, decimalLocation);
        hoursStr = trimString(hoursStr, ["."]);
        minStr = num2str(hours, 0, 2, 1, 0);
        minStr = substr(minStr, decimalLocation, strlen(minStr) - strlen(hoursStr));
        minStr = trimString(minStr, ["."]);
        realPart = str2int(hoursStr);
        decimalPart = str2int(minStr);
        finalMinutes = hoursStr + ":" + (int2str(60 * decimalPart / 100) == "0" ? "00" : int2str(60 * decimalPart / 100));
        return finalMinutes;
    }
    catch
    {
        return num2str(_hours, 0, 2, 1, 0);
    }
}

Wednesday, June 1, 2011

CLR Exception Catch

Query: How to catch CLR Exception?
Answer:  
catch (Exception::CLRError)
{
        info("Caught 'Exception::CLRError'.");
        netExcepn = CLRInterop::getLastException();
        info(netExcepn.ToString());
}

Tuesday, May 31, 2011

How to open an exe from Dynamics AX

 WinAPI::shellExecute(path);

SSRS A4 Print Layout

If you use Reporting Services, I bet you have spent a while trying to get the reports to print out as expected! I'm not sure why something that wastes so much of everybodies time (printing things out properly) is not well-known and fixed in software now - it should be impossible to get it wrong. The print knows its paper size, the software knows the paper size yet it prints out most of your document on one sheet and then a little strip on the next - obviously what you wanted!
Anyway, in reporting services there are some quirks that you need to know about in order to get your report correct.
1) Select Report - Report Properties and the Layout tab. There are paper sizes and margins in here. Note that the page sizes here need to match the physical paper size. I'm not sure what effect they have because it doesn't draws these on your report design!
2) You might think that is it BUT you then need to right-click on the grid area of the report in the layout view and choose properties (properties of the body of the report) and lo and behold there is another field here called "Size" which consists of width,height in measurement units (mm, inches etc) which defines the area of the report body. For some reason this is not restricted by the page size in report properties and you won't know if you make this too big! Anyway, this needs to equal the page size minus margins if you want it to fit on one sheet.

Example A4 paper is 210mm by 297mm so you set the report layout (in Report -> Report Properties) to these figures and then suppose you set the margins to 10mm all the way round. The report body should be set to 210 - 20 (for width) and 297 - 20 (for height) when in portrait or 297 - 20 (width) x 210 - 20 (height) when in landscape mode. It sounds really simple but it still takes time to find these things out!

More Links: http://blogs.msdn.com/b/bwelcker/archive/2005/08/19/454043.aspx

SSRS Direct Printing

http://blogs.msdn.com/b/brianhartman/archive/2009/02/27/manually-printing-a-report.aspx
http://connect.microsoft.com/SQLServer/feedback/details/573997/with-ssrs-2008-r2-microsoft-reporting-winforms-serverreport-render-method-returns-no-stream-identifiers-for-image-format
http://ouaesjamali.blogspot.com/2011/01/printing-ssrs-2008-r2-reports-from-c.html

Thursday, May 19, 2011

SSRS: Changing Ruler Settings

Change Regional Settings from English (United States) to English (Australia)
ie through Start > Control Panel > Regional and Language Settings.

Printing Dynamics AX Company Logo using in SRS

Query: Can I display company logo / image in SRS

Answer:
In order to do that create one metod in AX, X++ as following.
static public str getImage()
{
    CompanyInfo info = CompanyInfo::find();
    BinData binData = new BinData();
    str ret;
    ;
    //conver image to base64String as .net requirement
    bindata.setData(CompanyImage::find(curext(), info.TableId, info.RecId).Image);
    ret = binData.base64Encode();
    return ret;
}


Call this method in SRS and set the source of the image to be this method.
[DataMethod(), AxSessionPermission(SecurityAction.Assert)]
    public static System.Byte[] GetCompanyLogo()
    {
        string logoImage = (string)SessionManager.GetSession().CallStaticRecordMethod("CompanyInfo", "getImage");
        byte[] imageBytes = Convert.FromBase64String(logoImage);
        return imageBytes;
    }

Wednesday, May 18, 2011

ssrs unable to load client print control

Our Server environment : SQL2008 x64 SP2 Reporting Services on Windows Server 2008 x64,
Client PC environment: Windows XP SP2 with IE6 or higher, all users are login to Active Directory, users are not members of local Administrator or power user group.
Error: When a user printing a report  getting an error as "Unable to load client print control"
Solution that work for us: replace following files in sql 2008 with SQL 2008 R2
Program Files\Microsoft SQL Server\MSRS10.MSSQLSERVER\Reporting Services\ReportServer\bin
RSClientPrint-x86.cab
RSClientPrint-x64.cab
RSClientPrint-ia64.cab
Once you replace files on server side users wont get above error but it is required to do one time installation of this Active X component as a local Administrator or power user. If you are having large number of computers running on Active Directory environment you may create a MSI file with rsclientprint.dll and deploy using AD or SMS. Also I'm  recommending to add report server URL as a trusted site (add to Trusted sites) via Active Directory GP.
Hope this will help for somebody to sort out this "hectic" problem. We had very tough time to find out a proper solution for this "bug".

Wednesday, May 4, 2011

Dynamics AX Reporting Services Error: AX_CompanyName parameter issue

If you are getting a AX_CompanyName parameter issue when running a report, this is because your business connector configuration does not have a company name. Create a custom configuration and set the company ID to resolve the error.

PS: Make sure to restart reporting services, service.

Tuesday, May 3, 2011

Dynamics AX Reporting Services Error : Could Not Load Assembly

Query:
I am getting the following error when deploying reports,
 Could not load or find Microsoft.Dynamics.Kernel.Client.dll

Answer:
Make sure the Microsoft.Dynamics.Setup.ReportingServices.dll has been copied as per KB957312 before you do the reporting extensions installation was done.
Do the installation of KB957312
Run the application component of the KB957312 was applied to the AOS server.
Applied the Kernel component of KB 957312 to the server where the reporting extensions are applied.
Ran the installation and it worked properly.
Another option instead of copying the missing DLL's is to copy the AxReports.exe file from the c:\program files\Microsoft Dynamics AX\50\Reporting Services directory to the client directory where your Ax32.exe is located, and run it (AxReports.exe) from the client directory.
 Hope this helps someone.
PS: KB957312 refers to a 32 bit opearating system ony, but is works for a 64 bit operating system as well.

Dynamics AX Message Box

Query:
I need to ask a confirmation from the user for a operation. How can we achieve it?

Answer:
You can use the Box class available in Dynamics for it.
Box::

Sunday, May 1, 2011

Dynamics AX SRS Browser Not Showing up

Query:
I am getting a blank SRS report viewer using I try to view any report.

Answer:
This is because you might have select to hide the Active X control by right clicking and selecting hide. In order to show it back, open SRSReportView form from AOT, add another Active X control and now open the form. After opening the form right click on the form and select setup, select the first browser control from left and select visible to true.

Dynamics AX 2012 Unleashed

Found out today that my good friend David Weiner is writing book on Dynamics AX 2012, pre order it at http://www.amazon.com/Microsoft-Dynamics-AX-2012-Unleashed/dp/0672335484

Thursday, April 14, 2011

Recording Issue in windows 7 with PSR

Queries:
1- Is there any way in windows 7 I can record the issue I am having and send it to the authorities.

Answer:
There is a program called psr that you can open using Run window and using it for recording and entering comments.

Thursday, April 7, 2011

Compatibility Results for Microsoft SQL Server 2008 R2 and Office 2010 - March 2010 - Dynamics AX Sustained Engineering - Site Home - TechNet Blogs

Compatibility Results for Microsoft SQL Server 2008 R2 and Office 2010 - March 2010 - Dynamics AX Sustained Engineering - Site Home - TechNet Blogs

Ax Database Configuration Checklist Part 2 - Dynamics Ax Performance Team Blog - Site Home - MSDN Blogs

Ax Database Configuration Checklist Part 2 - Dynamics Ax Performance Team Blog - Site Home - MSDN Blogs

Welcome -- Ax Database Configuration Checklist part 1 - Dynamics Ax Performance Team Blog - Site Home - MSDN Blogs

Welcome -- Ax Database Configuration Checklist part 1 - Dynamics Ax Performance Team Blog - Site Home - MSDN Blogs

How to get SID to be used with AX Administration?

Question:
I have reinstalled my windows but want to use the same AX. The issue is my AX needs to be configured based on new SID. How to get the new SID?


Answer:
There is a very simple program that can be used to retrieve your new SID and then you can use it for configuration.
http://technet.microsoft.com/en-us/sysinternals/bb897417.aspx


Another way of doing it is by using the following command,
C:\> whoami /user