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);
}

Ledger Voucher creation Framework and x++ code to create ledger voucher

 Please click her for MS reference file Below is the out of the box example reference and code. SalesInvoiceJournalPostSubBill_Extension->...