13 October 2011

AX 2009 Retail Major Tables

// Following table are for ax retail 2009 if we do any retail transaction this two table will //affect
RBOTransactionTable
RBOTransactionSalesTrans

Get the Number Sequence through X++

//This following code to get the number sequece by using code.
//this following example describe to get purchID and ProjJournalID

ProjJournalTable _projJournalTable;
PurchTable _PurchTable;

_projJournalTable.JournalId = NumberSeq::newGetNum(ProjParameters::numRefProjJournalId()).num();
_PurchTable.PurchId = NumberSeq::newGetNum(PurchParameters::numRefPurchId()).num();

12 October 2011

Pass The Parameters to Class

To pass the parameter from the form selected record to class
1.Create a class as following code.
2.Add this class to Actions MenuItem.
3.In form add this MenuItemButton.
Open the form Select a record in the grid and click the button.
That record passed to the Main method. in info you will Vendor id get 2 times.
Cause New Method is calling and Post method is calling.

public class EmplProcess
{
VendTable _VendTable;
}
-
public void new(Common vTable)
{
_VendTable = vTable;
this.post();
}
-
public void post()
{
info(_VendTable.AccountNum);
}
-
public static void main(Args args)
{
Common _common;
EmplProcess _EmplProcess;

_common = args.record(); //getting the record from the form
_EmplProcess = new EmplProcess(_common);//passing the above record to the new method
_EmplProcess.post();// calling the post method
}
__________________________________________________________________________________--


While creating Object for class we can pass the parameter.
ex:

Class1 cls;
;
cls = new Class(VendTable);// this is Data Source name in Vend Table form

//in class override the new method and assign the Parameter.
public void new(VendTable vTable)
{
_VendTable = vTable;
}

11 October 2011

To attach a MS SQL database (.mdf) file with a missing log file

This is to attach a MS SQL database (.mdf) file with a missing log file (.ldf)

sp_attach_db 'MicrosoftDynamicsAx2012', 'D:\Program files\Microsoft SQL Server\DATA\MicrosoftDynamicsAx2012.mdf','D:\Program files\Microsoft SQL Server\DATA\MicrosoftDynamicsAx2012.ldf'

20 September 2011

Remove Base Enum elements during run time in Dialog

Hi All

Now you can remove the unwanted elements of your Base Enum during the run time in dialog box.

All you need to do id write this method in your dialog class

public void dialogPostRun(DialogRunbase _dialog)
{
FormRun formRun;
set removeValues;
SysDictEnum dictEnum;
int i,j, enumCount;
;
removeValues = new Set(Types::String);
removeValues.add("None");
removeValues.add("Requested");
removeValues.add("Sent");
acceptedValues = new Map(Types::Integer, Types::Enum);

dictEnum = new SysDictEnum(enumNum(SampleStatus));
enumCount = dictEnum.values();
super(_dialog);
formRun = _dialog.formRun();
formComboBoxControl = formRun.design().controlName(ResetStatus.name());
formComboBoxControl.clear();
for(i = 0; i {
if (removeValues.in(dictEnum.index2Label(i)))
{
continue;
}
formComboBoxControl.add(dictEnum.index2Label(i));
acceptedValues.insert(j, dictEnum.index2Value(i));
j++;
//

}

formComboBoxControl.selection(0);

}

Step 2:

public object dialog()
{
DialogRunbase dialog = super();

;
ResetStatus = dialog.addFieldValue(typeid(SampleStatus),sampleStatus,"SampleStatus");
dialog.allowUpdateOnSelectCtrl(true);
// write the above line in your dialog method.
ResetStatus.displayLength(40);

return dialog;
}


02 September 2011

Job to Create XML File from AX

Now You can create an xml file of the table using the following code

void CreateItemXML()
{

XmlDocument xmlDoc;
XmlElement nodeXml;
XmlElement nodeTable;
XmlElement nodeItem;
XmlElement nodeName;
XmlElement nodeGroup;
XmlElement nodeType;
InventTable inventTable;
#define.filename('e:\\item.xml')//Location of item xml file
;
xmlDoc = XmlDocument::newBlank();
nodeXml = xmlDoc.createElement('xml');
xmlDoc.appendChild(nodeXml);
//Creates xml for all the items which have the ItemGroupId "Television"
while select inventTable where inventTable.ItemGroupId == "Television"
{
nodeTable = xmlDoc.createElement(tablestr(InventTable));

//Add RecId as an attribute
nodeTable.setAttribute(fieldstr(InventTable, RecId),
int642str(inventTable.RecId));
nodeXml.appendChild(nodeTable);

//Add ItemId as a node
nodeItem = xmlDoc.createElement(fieldstr(InventTable, ItemId));
nodeItem.appendChild(xmlDoc.createTextNode(inventTable.ItemId));
nodeTable.appendChild(nodeItem);

//Add Item name as a node
nodeName = xmlDoc.createElement(fieldstr(InventTable, ItemName));
nodeName.appendChild(xmlDoc.createTextNode(inventTable.ItemName));
nodeTable.appendChild(nodeName);

//Add Item group as a node
nodeGroup = xmlDoc.createElement(fieldstr(InventTable, ItemGroupId));
nodeGroup.appendChild(xmlDoc.createTextNode(inventTable.ItemGroupId));
nodeTable.appendChild(nodeGroup);

//Add Item type as a node
nodeType = xmlDoc.createElement(fieldstr(InventTable, ItemType));
nodeType.appendChild(xmlDoc.createTextNode(strfmt("%1",inventTable.ItemType)));
nodeTable.appendChild(nodeType);
}
xmlDoc.save(#filename);
}

Service class to get the selected record and deleted matching records and refresh the form data source in D365 F&O

 [DataContractAttribute] class ABCUserProfilesBulkDeleteContract {         UserId userId;     [DataMemberAttribute('UserId')]     pu...