16 December 2011

Transfer Orders Post Picking List, Ship and Received in Code / auto post TransferOrder

Transfer Orders Auto Posting - Picking List, Ship and Received

To Post a TO receipt list in code, you can do the following:

void TO_PostPickList(InventTransferId transferId)
{
//will post the pick list.
InventTransferParmTable itpt;
InventTransferUpdPick itup;
;

//make sure we haven't already posted the pick list
//if the TO is changed, this will return a false positive and won't re-post the pick list
//TODO beef up the check on whether or not the Pick List should be postsed
select * from itpt where itpt.TransferId == transferId &&
itpt.UpdateType == InventTransferUpdateType::PickingList;

if(itpt.RecId == 0)
{

itpt.clear();
itpt.initParmDefault();

itpt.ParmId = RunBaseMultiParm::getSysParmId();
itpt.TransferId = transferId;
itpt.UpdateType = InventTransferUpdateType::PickingList;
itpt.PrintTransferPickingList = NoYes::No;
itpt.PickUpdateQty = InventTransferPickUpdateQty::All;
itpt.EditLines = NoYes::Yes;
itpt.ExplodeLines = NoYes::Yes;

itpt.InventDimFixedReceiveList = 0; // See note below on how to compute this.

itup = InventTransferUpdPick::newParmBuffer(itpt);

itup.run();
}
/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}
________________
To Post a TO receipt list in code, you can do the following:

void TO_PostReceipt(inventTransferId transferId)
{
InventTransferParmTable itpt;
InventTransferUpdReceive itur;
;

itpt.clear();
itpt.initParmDefault();

//TODO add check to make sure this is only posted if it needs to be posted

itpt.ParmId = RunBaseMultiParm::getSysParmId();
itpt.TransferId = transferId;
itpt.UpdateType = InventTransferUpdateType::Receive;
itpt.PrintTransferReceipt = NoYes::No;
//itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::Registered;
itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All;
itpt.EditLines = NoYes::Yes;
itpt.ExplodeLines = NoYes::Yes;

itpt.InventDimFixedReceiveList = 245; // See note below on how to compute this.

itur = InventTransferUpdReceive::newParmBuffer(itpt);

itur.run();

/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}
____________________
To Post a TO Ship in code, you can do the following:
void TO_PostShip(inventTransferId transferId)
{
InventTransferParmTable inventTransferParmTable;
InventTransferUpdShip inventTransferUpdShip;
;
inventTransferParmTable.clear();
inventTransferParmTable.initParmDefault();

//TODO add check to make sure this is only posted if it needs to be posted

inventTransferParmTable.ParmId = RunBaseMultiParm::getSysParmId();
inventTransferParmTable.TransferId = transferId;
inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;
inventTransferParmTable.PrintTransferReceipt = NoYes::No;
inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
inventTransferParmTable.EditLines = NoYes::Yes;
inventTransferParmTable.ExplodeLines = NoYes::No;

inventTransferParmTable.InventDimFixedReceiveList = 0;// See note below on how to compute this

inventTransferUpdShip = InventTransferUpdShip::newParmBuffer(inventTransferParmTable);

inventTransferUpdShip.run();
/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}

Transfer Orders Post Picking List, Ship and Received in Code / auto post TransferOrder

Transfer Orders Auto Posting - Picking List, Ship and Received

To Post a TO receipt list in code, you can do the following:

void TO_PostReceipt(inventTransferId transferId)
{
InventTransferParmTable itpt;
InventTransferUpdReceive itur;
;

itpt.clear();
itpt.initParmDefault();

//TODO add check to make sure this is only posted if it needs to be posted

itpt.ParmId = RunBaseMultiParm::getSysParmId();
itpt.TransferId = transferId;
itpt.UpdateType = InventTransferUpdateType::Receive;
itpt.PrintTransferReceipt = NoYes::No;
//itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::Registered;
itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All;
itpt.EditLines = NoYes::Yes;
itpt.ExplodeLines = NoYes::Yes;

itpt.InventDimFixedReceiveList = 245; // See note below on how to compute this.

itur = InventTransferUpdReceive::newParmBuffer(itpt);

itur.run();

/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}
_____________
To Post a TO receipt list in code, you can do the following:

void TO_PostReceipt(inventTransferId transferId)
{
InventTransferParmTable itpt;
InventTransferUpdReceive itur;
;

itpt.clear();
itpt.initParmDefault();

//TODO add check to make sure this is only posted if it needs to be posted

itpt.ParmId = RunBaseMultiParm::getSysParmId();
itpt.TransferId = transferId;
itpt.UpdateType = InventTransferUpdateType::Receive;
itpt.PrintTransferReceipt = NoYes::No;
//itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::Registered;
itpt.ReceiveUpdateQty = InventTransferReceiveUpdateQty::All;
itpt.EditLines = NoYes::Yes;
itpt.ExplodeLines = NoYes::Yes;

itpt.InventDimFixedReceiveList = 245; // See note below on how to compute this.

itur = InventTransferUpdReceive::newParmBuffer(itpt);

itur.run();

/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}
____________________
To Post a TO Ship in code, you can do the following:
void TO_PostShip(inventTransferId transferId)
{
InventTransferParmTable inventTransferParmTable;
InventTransferUpdShip inventTransferUpdShip;
;
inventTransferParmTable.clear();
inventTransferParmTable.initParmDefault();

//TODO add check to make sure this is only posted if it needs to be posted

inventTransferParmTable.ParmId = RunBaseMultiParm::getSysParmId();
inventTransferParmTable.TransferId = inventTransferTable.TransferId;//transferId;
inventTransferParmTable.UpdateType = InventTransferUpdateType::Shipment;
inventTransferParmTable.PrintTransferReceipt = NoYes::No;
inventTransferParmTable.ShipUpdateQty = InventTransferShipUpdateQty::All;
inventTransferParmTable.EditLines = NoYes::Yes;
inventTransferParmTable.ExplodeLines = NoYes::No;

inventTransferParmTable.InventDimFixedReceiveList = 0; // See note below on how to compute this.

inventTransferUpdShip = InventTransferUpdShip::newParmBuffer(inventTransferParmTable);

inventTransferUpdShip.run();
/*
#DEFINE.INVENTLOCATIONID_IDX(0)
#DEFINE.BATCH_IDX(1)
#DEFINE.LOCATION_IDX(2)
#DEFINE.PALLET_IDX(3)
#DEFINE.SERIALID_IDX(4)
#DEFINE.CONFIGID_IDX(5)
#DEFINE.INVENTSIZEID_IDX(6)
#DEFINE.INVENTCOLORID_IDX(7)

binary: 11110101
decimal: 245
*/
}

06 December 2011

Query Filter using query

1.To filter the Record based on the Enumvalues
Reference Form is : HRCCompLevel
class FormRun extends ObjectRun
{
QueryBuildRange qR;
HRCCompType compType;
}
_____
DS->HRCCompLevel->
public void init()
{
super();

//qR = SysQuery::findOrCreateRange(HRCCompLevel_ds.queryBuildDataSource(), fieldnum(HRCCompLevel, Type));

qR = SysQuery::findOrCreateRange(this.query().dataSourceTable(tablenum(HRCCompLevel)), fieldnum(HRCCompLevel, Type));
qR.status(RangeStatus::Locked);
}
________
DS->HRCCompLevel->
public void executeQuery()
{
qR.value(queryValue(queryValue(compType)));
qR.value('*');// this is to get all records

super();

}
---------------------
public int selectionChange()
{
int ret;

ret = super();
transferStatus = this.selection();
InventTransferTable_ds.executeQuery();
return ret;
}
_________________________________________________________________
_________________________________________________________________
2.
public void init()
{
super();
qR = SysQuery::findOrCreateRange(this.query().dataSourceTable(tablenum

(InventTransferTable)), fieldnum(InventTransferTable, TransferStatus));
}
________________

public void executeQuery()
{
str queryExpression;
;
queryExpression = '(' +
queryValue(RBOInventTransferStatus::Created) + '.' +

Enum2str(RBOInventTransferStatus::Received) + '.'+
Enum2str(RBOInventTransferStatus::Shipped) + ')';

if(transferStatus == RBOInventTransferStatus::All)
{
qR.value('*');
}
else
qR.value(queryValue(queryValue(transferStatus)));

super();

}

25 November 2011

How to create a project with specific layer objects / To get layer wise modifications

Step 1: Create a new project.

You can rename your project as desired, we'll call it Project_USR_Layer for now. Then open the newly created project

Step 2: Choose Advanced Filter/Sort from the toolbar.


If you are into keyboard short-cuts, you can use Ctrl-F3 for this as well.
A new dialog pops up

I like my objects grouped in the project as they are grouped in the AOT, so I've chosen Groupings - AOT.


Step 3: Select the required objects.

Use the Select button on the dialog to select the objects you require for your project.
We wanna select all AOT objects from a specific layer, so we'll use the UtilLevel field in the selection criteria


From the screenshot you can see that all objects from the USR layer are selected. If desired, you can limit the type of AOT objects for your project as well, by using the recordType field.

Confirm twice and the objects are added to your project. This may take some time, so be patient :-)

Similar challenge:


You can use the same method for selecting AOT objects modified/created by a specific programmer. Just set different selecting criteria in your query.

02 November 2011

Create & Post Inventory Journal in AX 2009 / Inventory movement journal code

Create & Post Inventory Journal in AX 2009
Following is job which will create and post the Inventory Journal in ax 2009 :-

static void createMovJournal(Args _args)
{
InventJournalTable journalTable;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventTable inventTable;
InventDim inventDim;
Counter cnt;
InventJournalCheckPost journalCheckPost = new InventJournalCheckPost();
DialogButton dbtn;
;

journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);

// Init JournalTable

journalTable.clear();

journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);

journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));

// Init JournalTrans
select firstonly inventTable;
for(cnt=1;cnt<10;cnt++)
{
journalTrans.clear();
journalTransData.initFromJournalTable();

journalTrans.TransDate = systemdateget() + 1 div 2;
journalTrans.ItemId ='1103'; //inventTable.ItemId;
journalTrans.Qty = 100;
journalTrans.CostAmount = 100;
journalTrans.LedgerAccountIdOffset='110170';

// Dimension details

inventDim.InventLocationId = '11';
journalTrans.InventDimId ='00000061_069'; //InventDim::findOrCreate(inventDim).inventDimId;

journalTransData.create();



}

journalTable.insert();

// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())

if(box::yesNo("Do you want to Post Now?",DialogButton::No)==DialogButton::Yes)
{
InventJournalCheckPost::newPostJournal(journalTable).run();
}
else
{
box::info("Not Posted");
}
info("done");

}

01 November 2011

Changing numerals to text in Indian Format amount in words India

Changing numerals to text in Indian Format

static TempStr numerals2Txt_IN(real _num)
{
int numOfPennies = (decround(frac(_num), 2) * 100) mod 100;
real test = _num - frac(_num);

int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, lakhs, crores;

int64 temp;
str 200 returntxt;
str 200 pennytxt;
int penny;

real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}

real checkPower(real _test, int64 _power)
{
int64 numOfPower;

if (_test >= _power)
{
numOfPower = _test div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower mod 100;
}
if (numOfPower >= 20)
{
temp = numOfPower div 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower mod 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower mod 10;
}
switch(_power)
{
case 10000000 :
{
returntxt = returntxt + ' ' + Crores;
_test = modOperator(_test, 10000000);
break;
}
case 100000 :
{
returntxt = returntxt + ' ' + lakhs;
_test = modOperator(_test, 100000);
break;
}
case 1000 :
{
returntxt = returntxt + ' ' + thousands;
_test = modOperator(_test, 1000);
break;
}
case 100 :
{
returntxt = returntxt + ' ' + hundreds;
_test = modOperator(_test, 100);
break;
}
}
}
return _test;
}

#Define.text_1('One')
#Define.text_2('Two')
#Define.text_3('Three')
#Define.text_4('Four')
#Define.text_5('Five')
#Define.text_6('Six')
#Define.text_7('Seven')
#Define.text_8('Eight')
#Define.text_9('Nine')
#Define.text_10('Ten')
#Define.text_11('Eleven')
#Define.text_12('Twelve')
#Define.text_13('Thirteen')
#Define.text_14('Fourteen')
#Define.text_15('Fifteen')
#Define.text_16('Sixteen')
#Define.text_17('Seventeen')
#Define.text_18('Eighteen')
#Define.text_19('Nineteen')
#Define.text_20('Twenty')
#Define.text_30('Thirty')
#Define.text_40('Forty')
#Define.text_50('Fifty')
#Define.text_60('Sixty')
#Define.text_70('Seventy')
#Define.text_80('Eighty')
#Define.text_90('Ninety')
#Define.text_100('Hundred')
#Define.text_1000('Thousand')
#Define.text_100000('Lakh')
#Define.text_10000000('Crore')
#Define.text_and('Rupees and')
#Define.text_paise('Paise Only')
#Define.text_ruppe('Rupees Only')

ones[1] = #text_1;
ones[2] = #text_2;
ones[3] = #text_3;
ones[4] = #text_4;
ones[5] = #text_5;
ones[6] = #text_6;
ones[7] = #text_7;
ones[8] = #text_8;
ones[9] = #text_9;
ones[10] = #text_10;
ones[11] = #text_11;
ones[12] = #text_12;
ones[13] = #text_13;
ones[14] = #text_14;
ones[15] = #text_15;
ones[16] = #text_16;
ones[17] = #text_17;
ones[18] = #text_18;
ones[19] = #text_19;

tenths[1] = 'Not used';
tenths[2] = #text_20;
tenths[3] = #text_30;
tenths[4] = #text_40;
tenths[5] = #text_50;
tenths[6] = #text_60;
tenths[7] = #text_70;
tenths[8] = #text_80;
tenths[9] = #text_90;

hundreds = #text_100;
thousands = #text_1000;
lakhs = #text_100000;
crores = #text_10000000;



test = checkPower(test, 10000000);
test = checkPower(test, 100000);
test = checkPower(test, 1000);
test = checkPower(test, 100);

if (test >= 20)
{
numOfTenths = test div 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths mod 10;
test = test mod 10;
}
if (test >= 1)
{
numOfTenths = real2int(test);
returntxt = returntxt + ' ' + ones[numOfTenths];
}

if (numOfPennies)
{
if (numOfPennies >= 20)
{
penny = numOfPennies div 10;
pennytxt = tenths[penny];
numOfPennies = numOfPennies mod 10;
}
if (numOfPennies >= 1)
{
pennytxt = pennytxt + ' ' + ones[numOfPennies];
}
returntxt = returntxt + ' ' + #text_and + ' ' + pennytxt + ' ' +#text_paise;
}
else
{
returntxt = returntxt + ' ' + #text_ruppe;
}

return returntxt;
}

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

29 July 2011

Set progress on operation

we can show the progress of the operation using following code
static void Progress(Args _args)
{
PurchTable _purchTable;
PurchLine _purchLine;
#Macrolib.AviFiles
SysOperationProgress progress = new SysOperationProgress();
;


progress.setCaption("Task");
progress.setAnimation(#AviUpdate);

while select _purchTable join _purchLine where _purchLine.PurchId == _purchTable.PurchId
{
progress.setText("Purchline is getting");//this will show the operation progress
}






}

07 June 2011

Store image in table

Create a table with Container Datatype
IN form take a method getImage() write the following code.
_path = "Image path"
void getImage()
{
Bindata binData = new BinData();
FilePath _path;
ImageStore _ImageStore;

;
_path = "D:\India_flag.gif"; // file path
binData.loadFile(_path);

_ImageStore.ItemImage = binData.getData();
_ImageStore.doInsert();
}
__
take a button and call this method there:
void clicked()
{
super();

element.getImage();
ImageStore_ds.executeQuery();

}

Make Form/Report run automatically when dynamics Ax Starts

When ax starts Kernel Creates an instance of Info class .
Info contains StartupPost() method used to execute the code every time ax starts.

Following example opens InventTable Form automatically when you start ax.

void startupPost()
{
SysSetupFormRun formRun;
Args args = new Args();
;

args.name(formstr(InventTable));
formRun = classfactory::formRunClassOnClient(args);
formRun.init();
formRun.run();
formRun.detach();
}
__

create Purchase order and invoice programmatically using x++ code

Following Job creates the Purchase order from code and post the invoice by making use of PurchFormLetter class.
static void Dev_CreatePO_and_Invoice(Args _args)
{
NumberSeq numberSeq;
Purchtable Purchtable;
PurchLine PurchLine;
PurchFormLetter purchFormLetter;

;

ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(purchParameters::numRefPurchaseOrderId().NumberSequence,true);

// Initialize Purchase order values
Purchtable.initValue();
Purchtable.PurchId = numberSeq.num();
Purchtable.OrderAccount = '3000';
Purchtable.initFromVendTable();

if (!Purchtable.validateWrite())
{
throw Exception::Error;
}
Purchtable.insert();

// Initialize Purchase Line items
PurchLine.PurchId = Purchtable.PurchId;
PurchLine.ItemId = 'B-R14';
PurchLine.createLine(true, true, true, true, true, false);
ttscommit;

purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchtable, // Purchase record Buffer
"Inv_"+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date


if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}
__
Change the documentstatus to packingSlip , if you want to post packing slip.
Enjoy ....Invoicing through Code.

27 May 2011

Multi selected Records getting in grid

// IN form Gird select some records and click button. in button properties MultiSelect: YES
void clicked()
{
CustTable _CustTable;
;

super();

if(CustTable_ds.anyMarked())
{
_CustTable = CustTable_Ds.getFirst(1,false);
while(_CustTable)
{
info(_CustTable.AccountNum);
_CustTable = CustTable_Ds.getNext();

}
}
}

DictTable and DictField

static void SystemClassesFields(Args _args)
{
SysDictTable dictTable;
DictField dictField;
Common common;
Counter counter;

;

dictTable = new SysDictTable(tableNum(CustTable));

for (counter=1; counter<=dictTable.fieldCnt(); counter++)
{
dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(counter));

if (dictField.isSystem())
{

info(strfmt("System field: %1", dictField.label()));
info(strfmt("System field: %1", dictField.name()));
}
else
info(strfmt("User field: %1", dictField.label()));
}
}

Common

static void Common(Args _args)
{
Common common;
CustTable custTable;
;

common = custTable;

if (common.tableId == tablenum(custTable))
{
while select common
{
info(common.(fieldnum(custTable, name)));
}
}
}

working with table buffers

static void OneCursor(Args _args)
{
CustTable custTable, newCustTable;
;
select firstonly custTable;

newCustTable = custTable;
}
--
static void TwoCursors(Args _args)
{
CustTable custTable, newCustTable;
;
select firstonly custTable;

newCustTable.data(custTable);
}
--
static void DataDic_MultipleCursors(Args _args)
{
CustTable custTable, newCustTable;
;
while select custTable
{
newCustTable.data(custTable);
//info(newCustTable.AccountNum);
}

}

20 May 2011

Time Field Comparison

// This is a job to understand about time values comparison and time field values comparison //using dialog
static void TimeComparison(Args _args)
{
TimeofDay fromTime,toTime; // Time variables
//TimeDate tbTime; // Table Buffer
Dialog dlg = new Dialog("TimeComparision");// object created for Dialog
dialogField dlgField,dlgField2;// Dialog Fields
TimeofDay fTime,tTime; // Time variables
;


dlgField = dlg.addFieldValue(typeid(TimeofDay),"","FromTime");
dlgField2 = dlg.addFieldValue(typeid(TimeofDay),"ToTime","ToTime");

if(dlg.run())
{
fromTime = dlgField.value();
toTime = dlgField2.value();
}

// fromTime = str2time("03:00:00 am");// we can change the time into string format
// toTime = str2time("04:00:00 am");


if(fromTime < toTime) { info("This is the small time"); info(time2str(fromTime,1,1)); } else if(fromTime > toTime)
{

info("From Time should be less than To time ");
info(time2str(toTime,1,1));
}
else
info("Enter the time");
//-----------------------------
// To compare we can use this function: str2time("11:00:00 am")

//while select tbTime where tbTime.FromTime == str2time("11:00:00 am")
//{
//print tbTime.FromTime;
//info(time2str(tbTime.FromTime,1,1));

//}

//print time;
//pause;

tTime = str2time("03:00:00 am");
tTime = str2time("04:00:00 am");

if(tTime == str2time("3:00:00:am"))
{
print tTime;
}
pause;

}

16 May 2011

Crosscompany to get data from other companies / Get the data from other companies

CrossCompany is the Keyword to get the data from other companies..

static void CrossCompany_test(Args _args)
{
CustTable custTable;
container conCompanies = [ 'USMF', 'USRT', 'USSI' ]; // you can assign the selected company
str comp;
;

while select crossCompany : conCompanies * from custTable
{
info( custTable.AccountNum + " : " + custTable.name() + " : " + custTable.dataAreaId);
}


}

Create virtual company accounts

Virtual company accounts contain data that is shared across company accounts. This type of account enables users to post information in one company that is available to another company.

Prerequisites

Requirements to create or modify a virtual company accountare as follows:

Must be running a single instance of the Application Object Server (AOS). All other AOS computers must be shut down.

Must be logged in as an administrator.

Only one active client connection is allowed.

Create a virtual company account
Click Administration > Setup > Virtual company accounts.

Enter the company identification in the Company accounts field.

Enter the name of the virtual company in the Name of company accounts field.

Click the Company accounts tab.

Select the company accounts to participate in the virtual company.

To add a virtual company account, select the company name under Remaining company accounts and then click the left arrow (<) to move it to the Selected company accounts list. To remove a virtual company account, select the company name under Selected company accounts and then click right arrow (>) to move it to the Remaining company accounts.

Click the Table collections tab and select the table collections that contain the specific tables that you want to share in the virtual company.

To add a table collection, select the table collection name under Remaining table collections and then click the left arrow (<) to move it to the Selected table collections list. To remove a table collection, select the table collection name under Selected table collections and then click the left arrow (>) to move it to the Remaining table collections list.

Table collections are groups of tables. They can be created by developers through drag-and-drop functionality in the Application Object Tree (AOT).

Shut down and restart the Microsoft Dynamics AX client.

You must restart the Microsoft Dynamics AX client to update the client with the new virtual company account information.

09 May 2011

Query Filter in form

In new form->write a method in DS->

void filterOnVendTable()
{
QueryBuildRange vendorAccountFilter;
;
vendorAccountFilter = this.query().dataSourceNo(1).addRange(fieldnum(VendTable, AccountNum));
vendorAccountFilter.value("3000..3010");
}

____
Call this method in DS->Init()
public void init()
{
super();
this.filterOnVendTable();
}

05 May 2011

Close AXAPTA with X++ , shut down AX with X++ code

public static void shutdownAxapta()
{
SysGlobalCache cache = appl.globalCache();
info info;
;
cache.set(classstr(info), identifierstr(Autologoff), true);
info=new info();
info.shutDown(true);
}

02 May 2011

Dialog Field Validation

In Report this if for to check the null values.
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();

if(_CustAccount == "")
{
checkfailed("Enter the value");
}
else
ret = true;

return ret;
}
______
This is to validate based on the condition.
boolean getFromDialog()
{
boolean ret;
;
_CustAccount = dlgField.value();

if(_CustAccount >= "4000" && _CustAccount <="4010")
{
ret = true;
}
else
checkfailed("Enter the values bet ween 4000 to 4010");

return ret;
}

13 April 2011

10 April 2011

create slaes order programmatically using x++ code

void CreateSalesOrder(container con,CustAccount custAccount,Description custDescription)
{
NumberSeq num;
str customerRef;
str deliveryName;
str deliveryStreet;
ExternalItemId externalItemId;

;

//create sales table
salesTable.clear();
salesTable.initValue();

num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
newSalesId = num.num();

if (salesTable::exist(newSalesId))
{
num.abort();
checkFailed("@LIQ1977");
checkFailed(strfmt("@LIQ1978", newSalesId));
throw error("@SYS23020");
}

salesTable.SalesId = newSalesId;
num.used();

if(custDescription != "")
{
salesTable.SalesName = custDescription;
}

//fetch the customer details from cust table using account no selected from drop-down list
select * from custTable where custTable.AccountNum == custAccount;

salesTable.CustAccount = custTable.AccountNum;
salesTable.InvoiceAccount = custTable.InvoiceAccount;
salesTable.SalesType = SalesType::Sales;
salesTable.SalesStatus = SalesStatus::Backorder;
salesTable.CurrencyCode = custTable.Currency;

salesTable.CustGroup = custTable.CustGroup;
salesTable.DeliveryDateControlType = SalesDeliveryDateControlType::SalesLeadTime;

//Set dates as systemDateTime
salesTable.ReceiptDateRequested = systemdateget();
salesTable.ShippingDateRequested = systemdateget();

salesTable.PurchOrderFormNum = conpeek(con,4);
customerRef = substr(conpeek(con,7),7,2);
salesTable.CustomerRef = customerRef;
salesTable.LanguageId = #Language;
salesTable.DlvMode = #DlvMode;

//Init from cust table
salesTable.initFromCustTable();

//Overwrite customer address with the address from user file.
//concatenate string
deliveryName = conpeek(con,8) + ' ' + conpeek(con,9) + ' ' + conpeek(con,10);
salesTable.DeliveryName = deliveryName;
//concatenate string
deliveryStreet = conpeek(con,11) + ' \ ' + conpeek(con,12) + ' ' + conpeek(con,13);
salesTable.DeliveryStreet = deliveryStreet;

salesTable.DeliveryCity = strrtrim(conpeek(con,14));
salesTable.DeliveryState = strrtrim(conpeek(con,15));
salesTable.DeliveryZipCode = strrtrim(conpeek(con,16));
salesTable.ShipCarrierDeliveryContact = conpeek(con,17);

//Craete Sales Order
salesTable.insert();

// Create Sales Order Line
salesLine.SalesId = salesTable.SalesId;
salesLine.initFromSalesTable(salesTable);

externalItemId = conpeek(con,3);
//Get ItemId from custVendExternalItem table using externalItemId from file
select ItemId,RecId from custVendExternalItem where custVendExternalItem.ExternalItemId == externalItemId;
if(custVendExternalItem.RecId == 0)
{
throw error('@LIQ2648');
}
//Set sales item id from custVendExternalItem table
salesLine.ItemId = custVendExternalItem.ItemId;
salesLine.SalesUnit = InventTable::find(salesLine.ItemId).salesUnitId();
select * from inventTable where inventTable.ItemId == salesLine.ItemId;
salesLine.initFromInventTable(inventTable);

select * from inventDim where inventDim.InventLocationId == custTable.InventLocation && inventDim.InventSiteId == custTable.InventSiteId;

if(inventDim.RecId != 0)
{
salesLine.InventDimId = inventDim.inventDimId;
}
else
{
throw error("@LIQ1979");
}

//Set Qty as 1 by default as per business - Bo
salesLine.SalesQty = 1;
salesLine.ConfirmedDlv = salesTable.ShippingDateConfirmed;
salesLine.lineNum = SalesLine::lastLineNum(salesLine.salesId) + 1.0;
salesLine.LinePercent = 10;
salesLine.RemainInventPhysical = 1;
salesLine.RemainSalesPhysical = 1;
salesLine.DlvMode = #DlvMode;
salesLine.SalesStatus = SalesStatus::Backorder;
//salesLine.SalesPrice;
salesLine.setPriceDisc(inventDim);

//Insert sales line items
salesLine.insert();

}

31 March 2011

Dynamics Look Up Filter - task 19

One of my form's I want to display the purchase order numbers(in a drop down),whose status is "not invoiced"

Take a new form->new StringEdit control->lookup();
use the following code.
----

public void lookup()
{
PurchTable purchTable;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PurchTable), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(PurchTable));
;
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchId));
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchName));
sysTableLookup.addLookupfield(fieldnum(PurchTable,PurchStatus));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Backorder));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Received));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::Canceled));
queryBuildDataSource.addRange(fieldnum(PurchTable, PurchStatus)).value(enum2str(PurchStatus::None));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
_______________________________________
To filter PurchId values
To avoid the null values in Dynamic lookup

public void lookup()
{
PurchTable purchTable;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PurchTable), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(PurchTable));
;
sysTableLookup.addLookupfield(fieldnum(PurchTable, PurchId));

queryBuildDataSource.addRange(fieldnum(PurchTable, PurchId)).value("000010..000020");
//To avoid the null values in Dynamic lookup
//queryBuildDataSource.addRange(fieldnum(Test_Vend,Name)).value(SysQuery::valueNotEmptyString());
//queryBuildDataSource.addRange(fieldnum(Test_Vend,Name)).value('!="" ');



sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}

29 March 2011

To restrict the object by calling from another object.

//To execute the code only by calling some object.

//Take a table or form. form init()-> there is some code. that code has to execute only when ever //calling by the projTable. Means that form is having DS is ProjTable. then that code has to //execute.

if (element.args().dataset() == tablenum(ProjTable))
{
// while select Regulatory
// DO the code..
}

Records get from Form in cache Records

//To get the record in form which is in currently in Datasource:
//Take a table buffer. Use the following code.

Regulatory _Regulatory ;
;
for ( _Regulatory = Regulatory_ds.getFirst(); _Regulatory; _Regulatory = Regulatory_ds.getNext())
// above line Regulatory_ds is the DataSource_DS
{
// get the records here one by one.
}

15 March 2011

Adding Find\Filter functionality on Display method

Override Context method of Form control which is using display method and provide code for filter. E.g I have done below for PhysicalInvent field of InventOnHandItem form.

void context()
{

int selectedMenu;
real test;
formrun fr;
Args ag;
Itemname strtext;
querybuilddataSource qb1;
queryrun qr;
query q;
PopupMenu menu = new PopupMenu(element.hWnd());
int a = menu.insertItem('Find');
int b = menu.insertItem('Filter');
int c = menu.insertItem('Remove Filter');


selectedMenu = menu.draw();

switch (selectedMenu)
{
case -1:
break;

case a:
ag = new args('SysformSearch');
fr = new formrun(ag);
fr.run();
fr.wait();
strtext = fr.design().controlName('FindEdit').valueStr();
if(strtext)
{
q = inventSum_Ds.query();
qb1 =q.dataSourceTable(tablenum(InventSum));
QB1.addRange(FieldNum(InventSum,PhysicalInvent)).value(SySQuery::value(strtext));
INVENTSUM_DS.query(Q);
INVENTSUM_ds.executeQuery();
}
break;

case b:
InventSum_DS.filter(FieldNum(InventSum,PhysicalInvent),Sysquery::value(InventSum.PhysicalInvent()));
break;

case c :
InventSum_DS.removeFilter();
break;

Default:
break;
}

}

09 March 2011

AX 6.0 some features in Development

Hi
All click this link to know some of the feature of Dynamics Ax 6.0 (2012)
Click Here

Current Time task 18

static void getTime(Args _args)
{
int hour,minute;
;
hour=timeNow()/3600; // return the current time only hours
minute=((timeNow() mod 3600)/60); // return the minutes
info(strfmt("Time - %1:%2",hour,minute));

}

28 February 2011

Table methods - task 17

Table methods using ValidateWrite() ValidateDelete() initValue() ModifiedField()

Click Here to download the XPO with ID values

initValue()
This method executes while creating new record to initialize a value, here I am assigning user id to the userID field.

public void initValue()
{
super();

this.UserId = curuserid();
}

ValidateDelete()
while deleting a record if we want to put any validation we can use this method. Here once I delete a record populating a info that deleted record.

public boolean validateDelete()
{
boolean ret;

ret = super();

info(this.AccountNum);

return ret;
}

ValidateWrite()
This method will get to fire when we update a record. here I am using to check mandatory field for address AccountNum

public boolean validateWrite()
{
boolean ret;
;

if(this.Address != "")

ret = super();
else
warning(" Please fill the address value");

return ret;
}

ModifiedField()
This method will execute if modified a record value, this works based on the field value.
Here I am using to fill the name field value according to the AccountNum

public void modifiedField(fieldId _fieldId)
{
CustTable ct;
;
super(_fieldId);

switch(_fieldId)
{
case fieldNum(Cust_new,AccountNum) :
{
this.Name = CustTable::find(this.AccountNum).Name;

}
break;
}

}

25 February 2011

working with Task form method

Task() in form
The task is using keys want to do some even
Here using CTRL+G I am closing the form.
so I am using task method.
public int task(int _taskId)
{
int ret;

ret = super(_taskId);// task Id will get keys ID value
if(_taskId == 2855)
element.close();

return ret;
}

Layer wise object find UtilElements

UtilElements
static void Test_UsrTable_Find(Args _args)
{
Utilelements utilElements;
;
while select utilElements where utilElements.recordType == UtilElementType::Table
&& utilElements.utilLevel == utilentryLevel::usr
{
info(utilElements.name);
}

}

22 February 2011

working with args

1.This is user defined form name is Test_form
this is form is calling in Address table.
Test_form->init()

If(element.args().dataset() == tablenum(address))
{
info("this is calling from address form");
}
--
2.This is user defined form name is Test_Form_two
this is form is calling in Address table.

Test_Form_two-> init()
Public void init()
{
Address address;
;
If(element.args().dataset() == tablenum(address))
{

info("this is calling from address form");
address = element.args().record();
info(address.name));
//here getting the address table selected record and storing in address TB
//while initiating the form displaying info.
}

}

10 February 2011

AX Versions list and Application and Kernel versions

AX Versions list and Application and Kernel versions

Find method ()

Find Task 10 click here to download XPO with out ID values

FInd In Table:
public void modifiedField(fieldId _fieldId)
{
;
super(_fieldId);
switch(_fieldId)
{
case fieldNum(Cust_new,AccountNum) :
{
this.Name = CustTable::find(this.AccountNum).Name;
}
break;
}
}
--
Find in Form:
Form->DS->Field->modified()
public void modified()
{
CustTable ct;
;
super();

Cust_new.Name = CustTable::find(Cust_new.AccountNum).Name;
// Or we can use following code
//ct = CustTable::find(Cust_new.AccountNum);
//Cust_new.Name = ct.Name;
}

AX Instent Message on all forms Task 8

Task 8 Click here to download the xpo With ID values.

08 February 2011

Tax Invoice Report excise invoice report

Tax Invoice Report
click here to import xpo with ID values
----
public class ReportRun extends ObjectRun
{
CustInvoiceJour custInvoiceJour;
CustInvoiceTrans custInvoiceTrans;
TaxTrans taxTrans;
TaxData taxData;
SalesTable salesTable;
SalesLine salesLine;
SalesParmTable salesParmTable;
MarkupTrans markupTrans;
InventTrans inventTrans;
InventDim inventDim;
InventSerialId _InventSerialId;
ConfigTable configTable;

SalesId salesId;
TaxAmount bED;
TaxValue bEDTaxValue;
TaxAmount pEdCess;
TaxValue pEdCessTaxValue;
TaxAmount sECess;
TaxValue sECessTaxValue;
TaxAmount cSTorVAT;
TaxValue cSTorTaxValue;
MarkupValue mCharges;

real subTotal;
real sumofTotalAssessableValue;
real grandTotal;
real decOfGTotal;
real realOfGTotal;
real gGrandTotal;
real roundOff;
InventSerialId serial;
str ser;
Counter counter;
Counter counter1;
counter cnt;
real quantity;


//
InventSite inventSite;
Address address;
Addressing siteAddress;

ItemId itemid;
ConfigId config;

}
----
public void init()
{
;

try
{
if(element.args().parm())
{
this.query().dataSourceTable(tablenum(CustInvoiceJour)).addRange(fieldnum(CustInvoiceJour,SalesId)).value(element.args().parm());
salesId = element.args().parm();
this.query().userUpdate(false);
this.query().interactive(false);
super();
}
}
catch(exception::Error)
{
info("@GSY97");
}
// for SLNo
counter = 0;
cnt = 1;
}
----
public boolean fetch()
{
str s;

boolean ret;

ret = super();

// select sum(AssessableValue_IN) from salesLine
// where salesLine.SalesId == salesId;
//
// sumofTotalAssessableValue = salesLine.AssessableValue_IN;

select sum(AssessableValue_IN) from custInvoiceTrans
where custInvoiceTrans.SalesId == salesId;

sumofTotalAssessableValue = custInvoiceTrans.AssessableValue_IN;


select Value from markupTrans
join custInvoiceJour
where markupTrans.TransRecId == custInvoiceJour.RecId
&& markupTrans.TransTableId == custInvoiceJour.TableId
&& markupTrans.MarkupCode == "@SYS1655"
&& custInvoiceJour.SalesId == salesId;

MCharges = markupTrans.Value;

while select sum(TaxAmount) from taxTrans
group by TaxCode
join custInvoiceJour
where taxTrans.Voucher == custInvoiceJour.LedgerVoucher
&& taxTrans.TransDate == custInvoiceJour.InvoiceDate
&& custInvoiceJour.SalesId == salesId
{
if(taxTrans.TaxCode == "@GSY106")
{
bED = taxTrans.TaxAmount;
select taxData
where taxData.TaxCode == "@GSY106";
bEDTaxValue = taxData.TaxValue;
}
if(taxTrans.TaxCode == "@GSY107")
{
pEdCess = taxTrans.TaxAmount;
select taxData
where taxData.TaxCode == "@GSY107";
pEdCessTaxValue = taxData.TaxValue;
}
if(taxTrans.TaxCode == "@GSY108")
{
sECess = taxTrans.TaxAmount;
select taxData
where taxData.TaxCode == "@GSY108";
sECessTaxValue = taxData.TaxValue;
}
if(taxTrans.TaxCode == "@GSY81")
{
cSTorVAT = taxTrans.TaxAmount;
select taxData
where taxData.TaxCode == "@GSY81";
cSTorTaxValue = taxData.TaxValue;
}
else if(taxTrans.TaxCode == "@GSY109")
{
cSTorVAT = taxTrans.TaxAmount;
select taxData
where taxData.TaxCode == "@GSY109";
cSTorTaxValue = taxData.TaxValue;
}

}

subTotal = sumofTotalAssessableValue + (-bED) + (-pEdCess) + (-sECess);

grandTotal = subTotal + (-cSTorVAT) + mCharges;

decOfGTotal = (decround(frac(grandTotal), 2));
realOfGTotal = grandTotal - decOfGTotal;

if(decOfGTotal >= 0.50)
{
gGrandTotal = realOfGTotal + 1;
roundOff = gGrandTotal - grandTotal;
}

else
{
gGrandTotal = grandTotal - decOfGTotal;
roundOff = -decOfGTotal;
}

// select inventTrans
// join custInvoiceTrans
// where inventTrans.TransRefId == salesId
// join inventDim
// where inventDim.inventDimId == inventTrans.inventDimId;
//
// serial = inventDim.inventSerialId;
//

//while select inventTrans
// join custInvoiceTrans
// where inventTrans.TransRefId == salesId
// join inventDim
// where inventDim.inventDimId == inventTrans.inventDimId
// {
// // _InventSerialId = inventDim.inventSerialId;
// this.send(inventDim);
// }

element.execute(3);
element.execute(6);
//element.execute(4);
while select custInvoiceTrans
where custInvoiceTrans.SalesId == salesId
{
element.execute(4);
}

while select inventTrans
//join custInvoiceTrans where custinvoiceTrans.SalesId == salesId
where inventTrans.TransRefId == salesId


{
while select inventDim where inventDim.inventDimId == inventTrans.inventDimId
{

//this.send(inventDim);


itemid = inventTrans.ItemId;



element.execute(5);

}
}


while select configTable where configTable.ItemId == inventTrans.ItemId
&& configTable.ConfigId == inventDim.configId
{
// techDesc = configTable.TechnicalDescription;
//this.send(configTable);
element.execute(5);
}

//addres for site



// while select salesLine
// where salesLine.SalesId == salesId
// {
// itemid = salesLine.ItemId;
// element.execute(4);
// }


element.execute(1);
return ret;

}
----
For tax fields IN programable section

//BP Deviation documented
display real bED()
{
;

return -bED;
}
--
//BP Deviation documented
display real pEdCess()
{
;

return -pEdCess;
}
--
-----
//BP Deviation Documented
display Addressing siteAddr()
{


;
while select salesTable
where salesTable.SalesId == salesId
join inventSite where inventSite.SiteId == salesTable.InventSiteId
join address where address.Name == inventSite.SiteId
{
siteAddress = address.Address;
}


return siteAddress;
}
------
//BP Deviation Documented
display InvoiceId invoiceId()
{
;

select InvoiceId from custInvoiceJour
where custInvoiceJour.SalesId == salesId;

return custInvoiceJour.InvoiceId;
}
-----

07 February 2011

How to filter the report values based on condition with dialog Task 7

How to filter the report values based on condition with dialog Task 7
to download xpo file click here Import with out ID values

In report->

public class ReportRun extends ObjectRun
{
DialogField dialogField,dialogField2;
Counter cnt,cnt2;

}
-----------
public Object dialog(Object _dialog)
{

DialogRunbase dialog = _dialog;
;
dialog.addGroup("Returned Count");
dialog.caption("IR-ROC");
dialogField = dialog.addFieldValue(typeid(Counter),"RO Count","RO Count");


return dialog;
}
-----------
boolean getFromDialog()
{
;
cnt = dialogField.value();

return true;
}
-----------
public boolean fetch()
{
PDITable PDITable_Innter; // Table buffer

;
while select PDITable group by ContactNo // PDITable is Report Datasource
{
cnt2 = 0;
if(PDITable.ContactNo)
{
while select PDITable_Innter where PDITable_Innter.ContactNo == PDITable.ContactNo
{
if(PDITable_Innter.PDIStatus == PDIStatus::Returned)
{
cnt2 += 1;
if(cnt2 >= cnt)
{
this.send(PDITable);
break;
}
}

}

}
}

return true;
}

New sales id generation based on the Number sequence group Multiple Number Sequence

New sales id generation based on the Number sequence group Multiple Number Sequence Task 6
click here to download XPO
import with ID values.

04 February 2011

To Apply Color to a Field in Form

Select a Field in Design -> Properties-> Color Schema : RGB and
Change the BackGroundColor & ForeGroundColor

03 February 2011

Setup Alerts in Dynamics Ax

How to Setup Alerts in Dynamics Ax 4.0
To get screen shots doc click here
Step By step Process:
INTRODUCTION


This article describes how to set up Business Alerts in Microsoft Dynamics AX 4.0. This article also describes how to set the e-mail address from which Business Alert e-mail messages are sent.

MORE INFORMATION

Configure a user account to receive alerts

To configure a user account to receive alerts, follow these steps:
1. In the Navigation Pane, click Administration, and then click Users.
2. Select a user, and then click User Options.
3. Verify that the e-mail address where you want the user to receive alerts is in the E-mail field.
4. In the Receive alerts every (minutes) box, type 1.
5. In the Pop-up link destination list, click To alert.
6. In the Send alert as e-mail message list, click Define on each alert rule.
7. In the Show pop-ups list, click Define on each alert rule, and then click Apply.
8. Close the Options window.

Add the "E-mail distributor batch" job

The "E-mail distributor batch" job is the batch job that monitors and sends e-mail messages. To add the "E-mail distributor" batch job, follow these steps:
1. In the Navigation Pane, click Administration, expand Periodic, expand E-mail processing, and then click Batch.
2. In the "E-mail distributor batch" window, click Recurrence.
3. In the Recurrence window, click No end date.
4. Click Minutes.
5. In the Count box, type 1, and then click OK.
6. In the "E-mail distributor batch" window, click to select the Batch processing check box, and then click OK.Note You receive an Infolog message that resembles the following message:
Information: The E-mail distributor batch job is added to the batch queue.
7. Click Close to close the Infolog dialog box.
8. On the Tools menu, click Development tools, and then click Application Hierarchy Tree.
9. Expand Forms, and then double-click Tutorial_EventProcessor.
10. On the Tutorial_EventProcessor form, click Start, and then verify that the status is In waiting.

Set up a new alert rule

Alert rules define when alerts are sent and how they are received. To set up a new alert rule, follow these steps:
1. In the Navigation Pane, click General ledger, and then click Chart of accounts.
2. On the Overview tab, right-click a cell in the Account name column, and then click Create alert rule.
3. In the Alert me when area, select the field that you want to monitor with this alert rule in the Field list. For example, select Account name.
4. In the Event list, select the event that you want to trigger an alert. For example, select has changed.
5. In the Alert me for area, select the All records in Ledger chart of accounts option.
6. In the Alert me until area, select the No end date option.
7. In the Alert who area, select the user account that you want to receive this alert in the User ID list.
8. In the Also alert me by area, click to select the Show pop-ups check box.
9. Click to select the Send e-mail check box, and then click OK.
10. Close the "Manage alert rules" window.

Test the alert

To test the alert that you have set up, follow these steps:
1. In the Navigation Pane, click General ledger, and then click Chart of accounts.
2. On the Overview tab, change the name of the account for which you set up a new alert.
3. In the Navigation Pane, click Administration, click Periodic, click E-mail processing, and then click E-mail sending status.
4. The "E-mail sending status" window shows e-mail alerts that have been sent.

Set the e-mail address from which alerts are sent

You can set the e-mail address from which alerts are sent by selecting an e-mail template. To do this, follow these steps:
1. In the Navigation Pane, click Basic, click Alerts, and then click Alert parameters.
2. In the E-mail ID list, select the e-mail template from which you want e-mail alerts to be sent.

Descending order in Form Task 5

To show the record in Descending order Task 5
IN the form-> DS-> init()
1 write the following code:
this.query().dataSourceNo(1).addSortField(fieldnum(DatasourceTable , field), SortOrder::Descending);
Example:
this.query().dataSourceNo(1).addSortField(fieldnum(CustTable,AccountNum) ,SortOrder::Descending);

2 In DS-> ExecuteQuery()
while select CustTable order by AccountNum desc
{
}

02 February 2011

How to get the Main TableForm From Another Form Task 4

To get the GoTo Main Tableform in another form Task 4

Create an EDT -> with relation EDT == Table1.column
use the Created EDT in the table2 add the field to table2from now when you do go to main table for that field in the table2 form then actually it will take you to the table1From.

Add the table1Form to display menuItem; click here to download a xpo for sample example import xpo with out ID values

To Disable a Record in Form by Unchecking a Check BOX in that record Task 3

create a new method in form methods

void method1()
{
if(datasourcename.checbox == noyes::Yes)
{
datasource_ds.allowedit(false)
}
else
{
datasource_ds.allowedit(true)
}
}

Now call this method in your datasource active method and in the checkbox field's modified method

01 February 2011

28 January 2011

Working COM create Doc file

static void Com_word(Args _args)
{
COM wordApplication;
COM wordDocuments;
COM wordDocument;
COM wordRange;
FileName filename;
;
wordApplication = new COM("word.application");
wordApplication.visible(TRUE);
wordDocuments = wordApplication.Documents();
wordDocument = wordDocuments.add();
wordDocument.saveas("D:\\MyDocument.doc");
filename = "D:\\MyDocument.doc";
wordDocument.activate();
wordRange = wordDocument.range(0,0);
wordRange.insertafter("Test me how to create the excel file ");
//wordRange = wordDocument.range(6,19);

wordRange = wordDocument.range(11,26);
wordRange.italic(true);
// if(WINAPI::fileExists(filename))
// {
// WINAPI::deleteFile(filename);
// }
wordDocument.save();
wordDocument.close();
wordApplication.quit();
}

To start up message while opening AX

1. In server Open ->Dynamics AX Clint configuration
give the Message in start up message control
2. In Info Class->startupPost() method-> write a info message

FileOpen window with job select file or Browser window

static void Select_FileOpen(Args _args)
{
/*
This is the demonstration to select the file as a browser window
you can create fileOpen browser window
*/

Dialog dialog;
DialogField dialogField;
Filename filename;
;

dialog = new Dialog("FileOpen");
dialogfield = dialog.addField(typeid(Filenameopen), "File Name");
dialog.run();


if (dialog.run())
{
filename = (dialogfield.value());

}

info(filename);



}

27 January 2011

How to stop the journal posting in GL

Here we can stop the Journal Posting per each chart of Account
select one COA and follow step:
GL->Chart of Accounts -> General Tab -> Administration Group -> Locked in Journal
Check this Box

how to use Resources

To assign sysResource:
Create any button in form->properties->ButtonDisplay: ImageOnly
Property->NormalResource : 104
104 is the Resource ID:::Tools->DevTools->Embeded Resources

To assign User Resource:
Create any button in form->properties->ButtonDisplay: ImageOnly
roperty->NormalImage: select your Image in this area..

25 January 2011

Transfer of modifications from Development to test Environment

Transfer of modifications from Development to test

Close all connections to the files
Shut down all clients
Shut down AOS
Shut down Business connector

Copy the new and modified application files
axXXX.aod
axXXXen-us.ald

Paste files in Destination Environment
axXXX.aod
axXXXen-us.ald

Start the destination environment
Compile the entire AOT
Synchronize the entire database

20 January 2011

compare base enums in a query

Click here
static void Compare_Base_Enums(Args _args)
{
PurchStatus purchstatus;
PurchTable purchTable;
;

purchstatus = Global::enum2int(PurchStatus::Invoiced); // this statement returning baseEnum element value

while select purchTable where purchTable.PurchStatus < enum2int(PurchStatus::Canceled)
{
info(strfmt("%1",purchTable.PurchStatus));
}

}

11 January 2011

Random Generation of number

static void RandomGenerateEg(Args _args)
{
RandomGenerate objRG = new RandomGenerate();
Random objRandom = new Random();
;
//This generates random numbers specified within the given range
//info(int2Str(objRG.randomInt(10,55)));

//This generates random numbers
info(int2Str(objRandom.nextInt()));
}

generate sequence number

static void SequenceEg(Args _args)
{
Sequence objSeq = new Sequence("Test Sequence",8,10,250,1);
print objSeq.currval(); // Displays the current value of the object
while(1)
{
print objSeq.nextval(1);
pause;
}
}

working with TextBuffer class - separate values from string

static void TextBuffer(Args _args)
{
TextBuffer buffer;
str source;
;

source = "I am first,I am second,I am third";
buffer = new TextBuffer();
buffer.setText(source);

while (buffer.nextToken(0, ','))
{
info (buffer.token());
}
}

Working with Dialog

1.Dialog in Job:
static void Dialog_Ex(Args _args)
{
Dialog dlg = new Dialog("Customer");
DialogField df;
Name name;
ABC test;
;
df = dlg.addField(typeid(SysDate),'','');

if(dlg.run())
{
info(df.value());
}
}
2.Dialog in Class
class CreateDialog extends Runbase
{
Dialog dialog1;
DialogGroup dlgGrp;
DialogTabPage dlgDialogTabPage;
DialogField dlgCustAcc;
DialogField dialogCustName;

CustAccount custAccount;
Name custName;

#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
custAccount,
custName
#ENDMACRO
}
--
protected Object dialog(DialogRunbase dialog, boolean forceOnClient)
{
//Object ret;
;
//ret = super(dialog, forceOnClient);

dialog1 = super();
dialog1.caption("CustDetails");
dialog1.addTabPage("Gen");
dialog1.addGroup("Gen");
dlgCustAcc = dialog1.addFieldValue(typeid(CustAccount),"","Enter Customer");
dialogCustName = dialog1.addFieldValue(typeid(Name),"","custName");
dialog1.addTabPage("Setup");
dlgCustAcc = dialog1.addFieldValue(typeid(CustAccount),"","Enter Customer");
dialog1.addGroup("Setup");
dialogCustName = dialog1.addFieldValue(typeid(Name),"","custName");

return dialog1;
}
--
public container pack()
{
return [#CurrentVersion,#CurrentList,super()];
}
--
public boolean unpack(container packedClass)
{
Integer version = conpeek(packedClass,1);
container base;
boolean ret;
;

switch (version)
{
case #CurrentVersion:
[version,#CurrentList,base] = packedClass;
ret = super(base);
break;
default :
ret = false;
}

return ret;
}
--
public static void main(Args args)
{
CreateDialog cd;
;
cd = new CreateDialog();

if(cd.prompt())
{
cd.run();

}
}

10 January 2011

Working wtih Queries Query_Ex

1.Queries in Jobs
static void Query_Ex(Args _args)
{
Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qbr = qbd.addRange(FieldNum(salesTable,SalesId));
qbr.value("00078_036");
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
info(salesTable.CustAccount);
}
}
---------------------------
2.Queries in Reports
In Report -> Fetch Method write the following code for Range

public boolean fetch()
{
boolean ret;

Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;

//ret = super();
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qbr = qbd.addRange(FieldNum(salesTable,SalesId));
qbr.value("00078_036");//range value
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
this.send(salesTable);
}
return true;
}
-----
Code for with out range
public boolean fetch()
{
boolean ret;

Query q;
QueryRun qr;
QueryBuildDataSource qbd;
QueryBuildRange qbr;
SalesTable salesTable;;

//ret = super();
q = new Query();
qbd = q.addDataSource(TableNum(salesTable));
qr = new QueryRun(q);
while(qr.next())
{
SalesTable = qr.get(TableNum(salesTable));
this.send(salesTable);
}

return true;
}
-------
Query Run with DS
DataSource added in report SalesTable
Report->Fetch()
public boolean fetch()
{
boolean ret;

QueryRun qr = new QueryRun(this);
;
//ret = super();

while(qr.next())
{
SalesTable = qr.getNo(1);// 1 refer the 1st datasource.
this.send(SalesTable );
}

Add a field in AP-payment journal lines & vendTrans Table it has to update once we done posing Task

Task
Add a field in AP-payment journal lines it has to update once we done posting Click here

i have created a new field in vendtrans table. that field is available in LedgerJournalTrans table also.

Whenever i am doing AccountsPayment->Payment Journal->Post. the record gets stored in the vendtrans table.

(Before posting the record gets stored in the ledgerjournalTrans table and after posting the record is created in vendtrans table.) Now i want to store the value of my newly created field in vendtrans table.(that value gets stored in ledgerjournaltrans, but sfter posting when the same record is created in vendtrans table,but the newly created field value is empty in vendtrans table)
-
Follow these setups.

1. Add the field to the custVendTrans Map
2. Create a new mapping in the VendTrans of custVendTrans Map

CustVendTrans.ProjId == VendTrans.ProjId

3. Class - CustVendVoucher
In the Class declaration add a variable

ProjId updateProjId;///Kranthi

4. Add a new method to CustVendVoucher class

ProjId parmUpdateProjId(ProjId _projId = updateProjId)
{
;
updateProjId = _projId;
return updateProjId;
}

5. In the initCustVendTrans methid of CustVendVoucher class add this line

custVendTrans.ProjId = updateProjId;

6. Class - VendVoucher -> in the newVendVoucherJournal method of vendVoucher class place the below line of code

vendVoucher.parmUpdateProjId(_ledgerJournalTrans.ProjId);

7. Compile the two classes
8.Right click on the CustVendVoucher class and Add-Ins -> "Compile Forward" - which will compile all the classes inherited from this class

07 January 2011

Create form with X++ code ( Run time form )

static void createForm(Args _args)
{
Args args;
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
FormBuildGridControl formBuildGridControl;
FormBuildStringControl formBuildStringControl;
FormBuildStringControl formBuildStringControl2;
FormBuildTabControl formBuildTabControl;
FormBuildTabPageControl formBuildTabPageControl;
FormBuildTabPageControl formBuildTabPageControl2;
FormStringControl formStringControl;
FormGridControl formGridControl;
DictTable dictTable;
int idx;
int idx2;
int idx3;

;

// Create the form header.
form = new Form();

// Add a data source to the form. ID 77 refers to the CustTable.
dictTable = new DictTable(tablenum(CustTable));
formBuildDataSource = form.addDataSource(dictTable.name());
formBuildDataSource.table(dictTable.id());

// Create the form design.
formBuildDesign = form.addDesign("Design");
formBuildDesign.caption("myForm");

// Add tabbed page controls, a grid control, and string controls.
formBuildTabControl =
formBuildDesign.addControl(FormControlType::Tab, "Overview");

formBuildTabPageControl =
formBuildTabControl.addControl(FormControlType::TabPage, "Overview");
formBuildTabPageControl.caption("Overview");

formBuildTabPageControl2 =
formBuildTabControl.addControl(FormControlType::TabPage,"Details");
formBuildTabPageControl2.caption("Details");

formBuildGridControl =
formBuildTabPageControl.addControl(FormControlType::Grid,"Table Grid");
formBuildStringControl =
formBuildTabPageControl2.addControl(FormControlType::String,"Table String");
formBuildStringControl2 =
formBuildTabPageControl2.addControl(FormControlType::String,"Table String");

// Add data fields to controls.
formBuildGridControl.addDataField
(formBuildDataSource.id(),dictTable.fieldName2Id("AccountNum"));
formBuildGridControl.addDataField
(formBuildDataSource.id(),dictTable.fieldName2Id("Phone"));
formBuildGridControl.addDataField
(formBuildDataSource.id(),dictTable.fieldName2Id("Name"));
formBuildGridControl.addDataField
(formBuildDataSource.id(),dictTable.fieldName2Id("Address"));
formBuildStringControl.dataSource(formBuildDataSource.id());
formBuildStringControl.dataField(2);
formBuildStringControl2.dataSource(formBuildDataSource.id());
formBuildStringControl2.dataField(3);

args = new Args();
args.object(form);

// Create the run-time form.
formRun = classfactory.formRunClass(args);

formRun.run();
formRun.detach();

}

Comma separated Values find in string using container

To Separate the values in the string
1.
static void commaSeperateJob(Args _args)
{
str s= "kranthi,kumar,Myname";
int i=1,j;
str s1,s2;
container c;
;
j = strlen(s);
for(i = 1; i <= j ; i++) { if(substr(s,i,1) != ",") s1 += substr(s,i,1); if(i>1 && substr(s,i,1) == "," || i == j)
{
c = c + [s1];
s1 = "";
}
}
conview(c);
pause;
}
2.
---------------------
static void Job(Args _args)
{
container c;
str s;
;
s= "kranthi,kumar,Myname";
c = str2con(s,",");
conview(c);
}
---------------------
3.
static void Cont(Args _args)
{
container c;
str s,s2;
str s3[];
int i,k;
;
s= "one,two,three";

c = str2con(s,",");
k = conlen(c);
// conview(c);
for(i =1; i <= k; i++)
{
s3[i] = conpeek(c,i);
print s3[i];
}
pause;
}

03 January 2011

Box Example

static void Box_Ex(Args _args)
{
Box box;
;
if(box::okCancel("Test",1,"Enter the value","Ok"))
{
throw info("right");
}
else
{
throw error("Enter the correct value");
}
}

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->...