Tuesday, November 6, 2012

Mindbrations: AX2012 - How to control the visibility of FactBox on form thru X++

Mindbrations: AX2012 - How to control the visibility of FactBox on form thru X++: "AX2012 - How to control the visibility of FactBox on form thru X++"

'via Blog this'

Wednesday, October 24, 2012

Print Main Menu

Question: How can i print all elements of a main menu.

Answer: Use the following job, 


static void menuPrint(Args _args)
{

    SysDictMenu menu;
    SysExcelWorksheetHelper worksheetHelper;
    SysExcelHelper sysExcelHelper;
    SysExcelWorksheet worksheet;
    str menuToPrint;
    str worksheetName;
    int currentRow = 1;
    str fileName;
    str path;

    void reportLevel(SysDictMenu _sysDictMenu)
    {

        SysMenuEnumerator enumerator;

        if(_sysDictMenu.isMenuReference() || _sysDictMenu.isMenu())
        {
            path += _sysDictMenu.label() + "//";
            enumerator = _sysDictMenu.getEnumerator();
            while (enumerator.moveNext())
            {
                reportLevel(enumerator.current());
            }
        }
        else
        {   currentRow ++;
            worksheetHelper.setCellValue(2, currentRow, _sysDictMenu.label());
            path = "";
        }
    }

    ;

    sysExcelHelper = SysExcelHelper::construct();
    sysExcelHelper.initialize();

    menuToPrint = 'Roster';
    worksheetName = menuToPrint;
    worksheet = sysExcelHelper.addWorksheet(worksheetName);
    worksheetHelper = SysExcelWorksheetHelper::construct(worksheet);
    // Populate the header row with the appropriate field labels and format the columns
    worksheetHelper.addColumn(1, "Path", Types::String);
    worksheetHelper.addColumn(2, "Item", Types::String);
    worksheetHelper.addColumn(3, "Status", Types::String);
    worksheetHelper.addColumn(4, "Assigned To", Types::String);
    worksheetHelper.addColumn(5, "Notes", Types::String);
    reportLevel(SysDictMenu::newMenuName(MenuStr(Roster)));
    worksheetHelper.autoFitColumns();
    worksheetHelper.formatWorksheetTableStyle(sysExcelHelper.getOfficeVersion());


    // Generate the file using the current UTC date time (without the ‘:’ character)
    // since it is not allowed for file names.
    fileName =  "C:\\Windows\\Temp\\ExportToExcel.xlsx";

    sysExcelHelper.save(filename);
    sysExcelHelper.launchExcel();
}

Tuesday, August 28, 2012

Read / Write Files from document handling

Question:
How can you read / writes files from document handling?

Answer:

void fromFolderToDB(FilePath _path)
{
System.IO.DirectoryInfo         dir = new
System.IO.DirectoryInfo(_path);
System.IO.FileInfo[]            files;
System.IO.FileInfo              curFile;
System.Collections.IEnumerator  enumerator;
BinData                         binData;
DocuValue                       docuValue;
;
files = dir.GetFiles(_path);
enumerator = files.GetEnumerator();
while (enumerator.MoveNext())
{
curFile = enumerator.get_Current();
docuValue.clear();
binData.loadFile(curFile.get_FullName());   // get file content
docuValue.File      = binData.getData();
docuValue.FileName  = curFile.get_Name();
docuValue.insert(); // insert into DB
}
}
void fromDBToFolder(FilePath _path)
{
BinData                         binData;
DocuValue                       docuValue;
;
while select docuValue // load From DB
{
binData.setData(docuValue.File);
binData.saveFile(docuValue.FileName); // insert into file system
}
}
Make attention to CodeAccessPermission when reading/writing to file system
and when using CLR inside X++

Monday, August 13, 2012

CAL License or Server License for SQL Server in AX Environment

Question
Should we use CAL based licensing or server based licensing for SQL Server in AX Environment?

Answer
Please read the link from here

Wednesday, August 1, 2012

Matching Invoices to Portions of a Packing Slip

Question
Is there any way to find out invoices corresponding to individual packing slips


Answer
There is a link between InventTrans, CustInvoiceJourn and CustPackingSlipJour. This can be used to get the desired result. Also read this document.


Links
http://www.microsoft.com/en-us/download/details.aspx?id=23769

Thursday, July 26, 2012

Sending email through outlook in Dynamics AX

Question:
How can i send an email in AX through outlook?

Answer:

static void OutlookEmail(Args _args)
{
    SmmOutlookEmail smmOutlookEmail = new SmmOutlookEmail();

    ;
    if (smmOutlookEmail.createMailItem())
    {
        smmOutlookEmail.addEMailRecipient('asamad@moorestephens.com.au');
        smmOutlookEmail.addSubject("Test");
        smmOutlookEmail.isHTML(true);
        smmOutlookEmail.addBodyText('Test');
        smmOutlookEmail.sendEMail(smmSaveCopyofEmail::No);
    }
}

Thursday, July 19, 2012

AxUpdatePortal not working with SharePoint 2010

Question:
When trying to deploy files using AxUpdatePortal utility in a SharePoint 2010 environment, the utility is not working at all.

Answer:
Make sure you have completed all the steps mentioned in the KB 2278963.

Thursday, May 24, 2012

Dynamics AX License Tables

Question
I copied my clients database today to do some testing on live data. How can I make sure that the local licenses are intact.


Answer
Dynamics AX stores licenses data in two tables, 


1.SysLicenseCodeSort
2.SysConfig



If you copy the data from your local AX instances to client AX instance the layers code will be intact.



Wednesday, February 22, 2012

How to check filter is enabled on a form

Query:

How can i check if the filter is enabled on an AX Form.

Answer:

The actions user perform an an ax form are processed in a method called task. You can override that method to see task id 2855. If it is the value then filter is enabled.


Wednesday, February 15, 2012

Enable remote errors on SSRS



Query:


I am getting some errors when viewing SSRS reports on client machines but i can not see the full error because it is asking me to enable remote errors on ssrs. How can i do that on ssrs 2005.

Answer:
The setting is stored in the table named 'ConfigurationInfo ' on the report server. Just open the table and set Enable Remote Errors to true.

Sunday, January 15, 2012

How to increase scroll bar size in windows application?

Question:


How can i increase scroll bar size in a windows application based on .Net Business Connector ?


Answer:


You can use windows display properties under personalization for it.
Further reading

Wednesday, January 11, 2012

How TO Write an Edit Method

Question:
How to write an edit method?


Answer:
Suppose you have an integer field with allowed values of 0 and 1. We can use an edit method to show a check box instead. We just have to use this edit method as a display method on the form control.


public edit NoYesId IsAllowed(boolean _set, NoYesId _value)
{
    NoYesId ret;
    int actualValue;
    if (_set)
    {
        if(_value == NoYes::Yes)
        {
            actualValue = 1;
        }
        ttsbegin;
        this.IsAllowedInt = actualValue;
        this.update();
        ttscommit;
    }
    else
    {
        if(this.IsAllowedInt)
        {
            ret = NoYes::Yes;
        }
    }
    return ret;
}

Monday, January 9, 2012

Dynamics AX Business Connector : Client made two requests at the same time.

Question :

I received a following error in my application built on the middle ware of business connector, "Client made two requests at the same time.".

Answer:


This is happening because you might have a multi-threaded application using same AX session in two requests. What you can do to fix it is to use different session objects for different parallel threads.