Tuesday 18 August 2015

Settle Vendor Invoice/Payment through X++ code - AX 2012

Hello Guys..!

Here I'm sharing code for Settle Vendor Invoice/Payment through X++ 

Code:
-----------
static void VendorSettlement(Args _args)
{
VendTable vendTable;
VendTrans invVendTrans, payVendTrans;
SpecTransManager manager;
CustVendTransData custVendTransData;
;
vendTable = VendTable::find("12345");
// Find the oldest unsettled invoice
select firstonly invVendTrans  order by TransDate asc
                            where invVendTrans.AccountNum == vendTable.AccountNum &&
                            invVendTrans.TransType == LedgerTransType::Purch &&
                            !invVendTrans.closed;
// Find the oldest unsettled payment
select firstonly payVendTrans order by TransDate asc
                    where payVendTrans.AccountNum == vendTable.AccountNum &&
                    payVendTrans.TransType == LedgerTransType::Payment &&
                    !payVendTrans.closed;
ttsbegin;
// Create an object of the CustVendTransData class with the invoice transaction as parameter
custVendTransData = CustVendTransData::construct(invVendTrans);
// Mark it for settlement
custVendTransData.markForSettlement(vendTable);
// Create an object of the CustVendTransData class with the payment transaction as parameter
custVendTransData = CustVendTransData::construct(payVendTrans);
//mark it for settlement
custVendTransData.markForSettlement(vendTable);
ttscommit;
// Settle all marked transactions
if(VendTrans::settleTransact(vendTable, null, true,SettleDatePrinc::DaysDate, systemdateget()))
info("Transactions settled");
}


@Rahul Talasila

Wednesday 12 August 2015

Dataset parameter must reference a valid report parameter - Axapta 2012

Hello Guys..!

Issue :

 while deploying SSRS report from visual studio getting error in Axapta 2012

"Dataset parameter must reference a valid report parameter".

Reason :

If you have a dataset parameter in your report that references the report parameter that you moved to the parameter group, you must update the dataset parameter reference or you will get an error that the Dataset parameter must reference a valid report parameter. The following steps describe how to update the reference to the report parameter.

Solution :

-> The default naming convention for a report parameter is [DatasetName]_[DatasetParameterName]. In Model Editor, expand the dataset that contains a reference to the report parameter that you added to the parameter group, and then select the dataset parameter.

-> In the Properties window, select the Report parameter drop-down list and then select the report parameter that you added to the parameter group.

For more information go through below link
https://technet.microsoft.com/en-us/library/gg731925.aspx


@Rahul Talasila

Sunday 2 August 2015

How to change grid row color in listpage/form in Dynamics Ax 2012

Hello Guys...!

Problem

How to change grid row color in listpage/ form in Dynamics Ax 2012 ?

Solution :

Go to Form Datasource and override Displayoption() method and write code according to your requirement.

Example :

 public void displayOption(Common _record, FormRowDisplayOption _options)
{
    SalesTable prodtablelocal;
   
    prodtablelocal = _record;
   
    Switch(prodtablelocal.SalesStatus)
    {
    Case SalesStatus::Delivered:
    _options.backColor(65535); //Light Yellow
    //_options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Invoiced:
    _options.backColor(8421631); //Light Red
    //_options.affectedElementsByControl(Salestable_SalesId.id());
    Break;
    Case SalesStatus::Backorder:
    _options.backColor(65408); //Light Green
    //_options.affectedElementsByControl(Salestable_SalesId.id());
    _options.textColor(12582912);
    Break;
    }
}



@Rahul Talasila

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...