Wednesday, December 17, 2014

AX 2012 showing lookup from different (cross) company

I had a requirement in AX 2012 in which I had to show Customer Lookup from a different company. Our requirement was to provide user with two lookups on the Vendor Form (VendTable).

  1. One lookup - To select the company from which they want to see Customers
  2. Second lookup - Show Customers from the company selected on above lookup
To achieve this I added 2 fields in the table VendTable
  1. TargetCompanyId (EDT: SelectableDataAreaId)
  2. TargetCustAccount (EDT: CustVendAC) - Don't use CustAccount EDT, I tried this in AX2009 and it appeared to be using EDT relation and could not work.
After adding these fields, create a new relationship and add both of the above added fields in this relationship.

Drop the fields on the form and you will see Customer will appear from the company you have selected in the first lookup. Change company from the first lookup and see how data in the customer lookup changes.


Sunday, December 14, 2014

Calling Events of AX Form's Datasource

While working on AX 2012 Forms, we need to call form's datasource events every now and then from other events. Below is the example that shows how you can call any event like modified, validate etc. of a form's datasource from any other method.

Below example shows how you can call modified method of ItemId field under InventJournalTrans datasource.

FormDataObject          itemIdField;
itemIdField = inventjournalTrans_ds.object(fieldnum(InventJournalTrans, ItemId));
itemIdField.modified();
           

Monday, November 24, 2014

Installing Sharepoint 2010 foundation on Windows 7

While trying to Install Sharepoint 2010 on Windows 7 to setup Enterprise Portal, I was getting an error that Windows Server 2008 R2 is needed. I was able to install after adding following setting to the file in the setup directory.

File:
.../SharepointSetup/Files/Setup/Config.xml

Open the above mentioned file and add the following line to it.

<Setting Id="AllowWindowsClientInstall" Value="True"/>

After adding this line, the file would like something like that.

<Configuration>
<Package Id="sts">
<Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
</Package>

        <DATADIR Value="%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\14\Data"/>

<Logging Type="verbose" Path="%temp%" Template="Microsoft SharePoint Foundation 2010 Setup *.log"/>
<Setting Id="UsingUIInstallMode" Value="1"/>
<Setting Id="SETUP_REBOOT" Value="Never" />
<Setting Id="AllowWindowsClientInstall" Value="True"/>
</Configuration>

Once you add this line, run the setup again and you should be good to go.

Tuesday, November 26, 2013

AX 2012 how to get new number using Number Sequence

Question:

How to get new number in AX 2012 using Number Sequence

Answer:

NumberSeq num;
num = NumberSeq::newGetNum(RetailParametersEx2::numSLInternalRequisitionNumber());

AX 2012 Get Current Worker Id

Question:
How to get Current Worker Id in Dynamics AX 2012

Answer:
HcmWorkerRecId workerRecId = DirPersonUser::currentWorker();

Thursday, November 21, 2013

Debugging Enterprise Portal code in AX 2009/2012

File open dialog on AX 2012 form

Problem:
I want to show a file open dialog on AX 2012 form but when I click the open dialog button it doesn't respond.

Solution:
On Runbase OR Sys operations framework, all you have to do is set the EDT to FileNameOpen and dialog will appear, however, on AX form only setting the EDT will not do. You will need to add following methods to your form methods node.

str filenameLookupFileName()
{
    return "";
}

FilenameFilter filenameLookupFilter()
{
    return ["@SYS134052", #AllFilesName+#AllFilesExt];
}

str filenameLookupInitialPath()
{
    return "";
}

str filenameLookupTitle()
{
    return "Select a trade agreement to import";
}