Monday, May 6, 2013

Loop through the messages in an infolog

Here is a code which loops through the messages in the current infolog,

static void getWarnings(Args _args)
{
    SysInfoLogEnumerator            infoLogEnum;
    SysInfologMessageStruct         infoMessageStruct;
    WarningsTable                   warningsTable;//table to hold the warning
    ;

    warning('It is a warning 01'); 
    warning('It is a warning 02');
    warning('It is a warning 03');

    infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());

    while(infoLogEnum.moveNext())
    {
        infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());
        warningsTable.Warning = infoMessageStruct.message();
        warningsTable.insert();
    }
}

Sunday, August 21, 2011

You can correct a posted packing slip in AX 2012

In the previous versions, it was very difficult to correct a packing slip. you were supposed to reverse the original packing with negative quantity then posting a new packing slip with corrected data.
AX 2012 comes with a good functionality which can really help you to correct or cancel a posted packing slip both in sales and purchases.

After posting the purchase packing slip
go to the Receipt and click on Product Receipt, where you can see the list of packing slips posted. select the packing slip which you want to correct and click on correct.

The same form that is used for posting the original packing slip will get opened, now do the necessary changes to that packing slip(example: quantity) and post the packing slip. Now you can observe the changes to the posted packing slip.




Saturday, June 25, 2011

New And Deprecated Features of AX 2012

Here is a link where you can download the document containing new and deprecated features of AX 2012

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=d38bb877-7cf8-400e-8a50-47d4ebbaf4a6&displaylang=en

Tuesday, June 7, 2011

Overwrite system fields

You can Overwrite the system fields like createdby,createdDateTime etc by using
overwriteSystemfields() method.
table.overwriteSystemfields(true);

This method takes a boolean as parameter, whether to Overwrite or not.
You can make use of this method only at the time of inserting the records into the table.***You cannot do an update to the system fields...

Sunday, January 9, 2011

Updating The vendTrans Table

Hi the below code help you to insert custom created field values from a journal(LedgerJournalTrans) to the vendTrans table.

The insertion and updation of the vendTrans fields is done with the help of CustVendTrans Map

Follow the below setups when you add a new field to the ledgerJournalTrans and update it to vendTrans table...


1. Add the field to the custVendTrans Map - before that add field to ledgerJournalTrans and vendTrans.
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

Hope this code will help you...

Friday, December 24, 2010

Importing an XPO through code

This code helps to import an XPO using X++

static void importXPO(Args _args)
{
SysImportElements sysImportElements = new SysImportElements();
;

sysImportElements.newFile("C:\\Form_KranthiTest.xpo");/// this is your XPO filename
sysImportElements.parmImportAot(true);
sysImportElements.parmImportWithIds(false);///if you don't to import with IDvalues
sysImportElements.import();
}

Monday, December 13, 2010

Sending mails through outlook

This code open an mail window form - to which you can send parameters like email id , subject and body

static void sendEmailThroughOutlook(Args args)
{
SmmOutlookEMail smmOutlookEMail = new SmmOutlookEMail();
Object smmSendEmail;
;

args = new Args();
args.name(formstr(smmSendEmail));
args.caller(smmOutlookEMail);
smmSendEmail = classfactory.formRunClass(args);


if (smmSendEmail)
{
smmSendEmail.init();
smmSendEmail.setEmailTos("aaa@gmail.com");
smmSendEmail.setEmailSubject("Kranthi");
smmSendEmail.setAttachments(["C:\AIF\kranthi.txt"]);
smmSendEmail.run();
smmSendEmail.refreshControl();
smmSendEmail.wait();
}

}