Monday, 10 October 2016

To filter dimension value through code in ax 2012

qbdsProjTable = _query.dataSourceTable(tableNum(ProjTable));
           
        SysQuery::addDimensionAttributeRange(_query, qbdsProjTable.name(), fieldStr(ProjTable, DefaultDimension), DimensionComponent::DimensionAttribute, "Diving", "LineofBusiness", true);

Wednesday, 5 October 2016

Find Dimension Name based on default dimemsion

The following method can be created in DimensionDefaultingEngine class and used wherever required.



public static SysDim  umg_DefaultDimensionValue(DimensionDefault   _dimensionDefault, Description  _segmentName)
{
    DimensionAttributeValueSetStorage       dimensionStorage;
    Counter                                 i;
    SysDim                                  segmentValue;

    // Get dimension storage
    if (_dimensionDefault)
    {
        dimensionStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);
        for (i=1 ; i<= dimensionStorage.elements() ; i++)
        {
            if (DimensionAttribute::find(dimensionStorage.getAttributeByIndex(i)).Name == _segmentName)
            {
                segmentValue = dimensionStorage.getDisplayValueByIndex(i);
                break;
            }
            else
            {
                segmentValue = '';
            }
        }
    }
    return segmentValue;
}

Tuesday, 5 July 2016

Sales order creation using console apllication

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SalesOrderCreation.ServiceReference1;

namespace SalesOrderCreation
{
    class Program
    {
        static void Main(string[] args)
        {
            CreateSalesOrder();
        }
        static void CreateSalesOrder()
        {
            SalesOrderServiceClient client = new SalesOrderServiceClient();
               
            CallContext cc = new CallContext();
            cc.Company = "BM01";
            ServiceReference1.AxdSalesOrder so = new AxdSalesOrder();
          
            AxdEntity_SalesTable salesTable = new AxdEntity_SalesTable();

            AxdEntity_SalesLine salesLine = new AxdEntity_SalesLine();

            salesTable.CustAccount = "C000000007";
            salesTable.InvoiceAccount = "C000000007";

            salesTable.CurrencyCode = "USD";

            salesTable.ReceiptDateRequested = System.DateTime.Today;

            salesTable.Payment = "10D";
            salesTable.PurchOrderFormNum = "DevSuneela";

            salesLine.ItemId = "123456";
            

            salesLine.SalesQty = 20;

            salesLine.SalesUnit = "ea";
                      
            salesTable.SalesLine = new AxdEntity_SalesLine[] { salesLine };

            so.SalesTable = new AxdEntity_SalesTable[] { salesTable };

            so.DocPurpose = AxdEnum_XMLDocPurpose.Original;

            so.DocPurposeSpecified = true;
                       
            
            client.create(cc, so);

           
        }

    }
}

Thursday, 16 June 2016

Filter dimension values based on the dimension selected

To Filter standard and custom dimension values based on the dimension selected


public void lookup(FormControl _formControl, str _filterStr)
{

SysTableLookup sysTableLookup;

Query query;

QueryBuildDataSource qbdsDimensionFinancialTag,qbds,qbds1,qbds2;

QueryBuildRange qbrFinancialTagCategory;
 
//standard

DimensionAttributeValueSetItem valueSetItem;

DimensionAttribute dimAttribute;

DimensionAttributeValue dimAttributeValue;
 
str name,value;

container con;

OMOperatingUnit operatingUnit;
 
//standard

#define.MyCustomFinancialDimension('MyCustomFinancialDimension')

if( DimensionAttribute::findByName(Table1_Dimension.valueStr()).Type == DimensionAttributeType::CustomList)

{
 
query = new Query();

qbdsDimensionFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag));

qbrFinancialTagCategory = qbdsDimensionFinancialTag.addRange(fieldNum(DimensionFinancialTag, FinancialTagCategory));

qbrFinancialTagCategory.value(strFmt('%1', DimensionAttribute::findByName(Table1_Dimension.valueStr(), false).financialTagCategory()));

sysTableLookup = sysTableLookup::newParameters(tableNum(DimensionFinancialTag), _formControl);

sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Value), true);

sysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag, Description));

sysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag, FinancialTagCategory));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}
   else

{



value = Table1_Dimension.valueStr();


 
if(value == "CostCenter")

{
 
sysTableLookup = sysTableLookup::newParameters(tableNum(DimAttributeOMCostCenter), _formControl);

query = new query();

qbds = query.addDataSource(tableNum(DimAttributeOMCostCenter));

qbds.addRange(fieldNum(DimAttributeOMCostCenter,Value)).value(SysQuery::valueUnlimited());

sysTableLookup.addLookupfield(fieldNum(DimAttributeOMCostCenter, Value), true);
           

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}
 
if(value == "Brand")

{
 
sysTableLookup = sysTableLookup::newParameters(tableNum(DimAttributeOMDepartment), _formControl);

query = new query();

qbds = query.addDataSource(tableNum(DimAttributeOMDepartment));

qbds.addRange(fieldNum(DimAttributeOMDepartment,Value)).value(SysQuery::valueUnlimited());

sysTableLookup.addLookupfield(fieldNum(DimAttributeOMDepartment, Value), true);
         

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

}

}
 


 

Wednesday, 8 June 2016

To append string using computed column in View

public static server str POConfirmationJournal()

{
TableName viewName = tableStr(DESPurchOpenLines);
return SysComputedColumn::add(SysComputedColumn::returnField(viewName,identifierStr(PurchTable),fieldStr(PurchTable,PurchId)),
SysComputedColumn::cast(SysComputedColumn::returnLiteral('-1'), 'VARCHAR'));
 
}
 
 
 


 

Tuesday, 24 May 2016

To find Minimum DateTime from all records of a table

DateTimeUtil::applyTimeZoneOffset(vendPurchOrderJour.DESPODateTime, DateTimeUtil::getUserPreferredTimeZone());

Tuesday, 10 May 2016

Create lookup form and add the lookup form to the form control in AX 2012

1. To create lookup form, first create a query(Optional) with the required data sources and appropriate relations.
2. Create a lookup form with the query as datasource. Set the style property of the design to Lookup.
3. In the form init(), the following code has to be written after Super()

    element.selectMode(DirPartyTable_Name);

where DirPartyTable_Name is control in the grid.
4.Go the form control for which lookup form needs to be assigned(Navigate to the control in the design list ) and override lookupReference(Lookup) based on the field type and add the following code in the method
public Common lookupReference()
{

    Args                args;
    FormRun             formRun;
    DirPartyTable       selectedRecord;

    args = new Args();
    args.name(formStr(SalesRepLookup));
    args.caller(element);

    formRun = classfactory.formRunClass(args);
    formRun.init();
    formRun.selectRecordMode(this);
    this.performFormLookup(formRun);

    selectedRecord = formRun.selectRecordModeSelectedRecord();

    return selectedRecord;
}
That's it we are done with the lookup form.




Friday, 1 April 2016

To hide form tab page for a specific role

Please follow below steps to give specific access to form control

1.       Set needed permission on tab page\control property to manual
2.       Drag the tab to all permissions node under the permissions node
3.       Go to form related privilege- form> add-in> security tool> find related role and privilege
4.       Go to privilege and drag the form into privilege>permissions>forms node and then drag the tab.

5.       Now give no access on dragged tab page.

Thursday, 31 March 2016

SysOperation framework

http://devexpp.blogspot.in/2013/11/introduction-to-sysoperation-framework.html

Monday, 14 March 2016

Bundle batch process in AX 2012

Below is the link to bundle batch process in AX 2012

https://letsdodynamicsax.wordpress.com/2015/07/16/how-to-bundle-batch-process-in-ax-2012/

Open VS in CUS layer

1. To open VS in VS, properties of VS has to bet in Target as shown below
2. "E:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /AXConfig C:\Users\sbandy\Desktop\AXCUS.axc

where E:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe is the path where VS is installed and is the path where AX configuration is present.

Thursday, 10 March 2016

DrillThrough Report in SSRS

1.  Open the report for which DrillThrough functionality needs to be applied.
2.  Create a new datamethod as shown below
















3. Rename the newly added dataMethod to VoucherDrillThrough
4. open the dataMethod VoucherDrillThrough and we will find the newly added Business logic project added to the same solution as shown below.


5.  Navigate to View > Application Explorer > Visual Studio Projects > C# Projects > SRSDrillThroughCommon as shown below
6.  Double click SRSDrillThroughCommon C# project, it will be added to our solution as shown below. Then, right click Reference > Add Reference > in the Businesslogic (VendorInvoiceSpendReport.BL) as shown below



7. Double click on data method and add the namespace
using.Microsoft.Dynamics.AX.Application.Reports; and add the following method as shown in the screen shot below.


8. Now the Datamethod is ready, Select the field for which drillThrough is required as shown below and select textbox properties.


9. Write the expression by passing the required parameters using the datamethod name


10.Save and deploy.
11. Follow the below link to resolve the errors after deploying

https://community.dynamics.com/ax/b/ax2012r3technicalconsultantblog/archive/2015/05/12/dynamics-ax-2012-r3-report-deployment-error-with-visual-studio-2013-loading-this-assembly-would-produce-a-different-grant-set-from-other-instances

12. Redeploy it again and deploy.





Collapse/Expand in SSRS

1. Select the row for which collapse/expand has to be set and select row visibilty
set the properties as shown in the screen shot below
















In Screenshot SubtotalGrp is the textbox name of the above row(+/- button will appear) on which collapse/expand should work.

Sunday, 21 February 2016

To import a new model file in AX

1.Open Microsoft Dynamics AX Management Shell(Run as administrator) from Administrative tools
2. Run the following command in PS C:\Windows\system32>

Install-AXModel -File "C:\Users\sbandy\Desktop\Suneela\Direct_Energy_AX\Merged Models\6.STOPurch_CUSTOM" -Details



Tuesday, 2 February 2016

To run different designs in controller class

1. In main method 
static void main(Args _args)
{
    DESVendorSpendReportController controller;


    controller = new DESVendorSpendReportController();
    controller.parmReportName(ssrsReportStr(DESVendorInvoiceSpendReport, Reporting));
    controller.parmArgs(_args);

    controller.startOperation();
}
2. in PreRunModifyContract class
Protected void preRunModifyContract()
{
    DESVendorSpendReportContract   contract;
    NoYesId                        LE;
        super();
    contract   = this.parmReportContract().parmRdpContract() as DESVendorSpendReportContract;
    LE         = contract.parmsubtotalByLegalEntityAndVendor();
   
    if (LE )
    {
                            this.parmReportContract().parmReportName(ssrsReportStr(DESVendorInvoiceSpendReport,LEInvDateReporting));
    }
    }

Monday, 25 January 2016

Loopkup filter  based on another field  in SYSQUERY form 

The requirement is to filter one lookup field value based on another field selection in SysQuery form.

Follow the below steps to filter VendorAccount field based on legal entities selection

Example:

1. Create a new Query called DESVendorSpendReport having DataArea as Root and VendTable underneath it.
create a relation under VendTable like DataArea.id == VendTable.DataAreaid
2. Set AllowCrossCompany property of the Query to true.
3. Write the below code in SysQueryForm > Range(DataSource) > RangeValue(field) > Lookup method

public void lookup(FormControl _formControl, str _filterStr)
{

   CompanyInfo          companyInfo;
   Query                query;
   QueryBuildDataSource qbds;
   SysTableLookup       lookup;
   SysDictField         sysDictField;
   VendTable            vendTable;
   TmpSysQuery          tmpSysQuery;
   TmpSysQueryCompanyRange tmpSysQueryCompanyRange;
   Container               selectedCompanies;
   
   ;
   sysDictField = new SysDictField(Range.Table_Id, Range.Field_Id);
   if (sysDictField.label() == "Vendor account")
   {
        recordsMarked = CompanyRanges_DS.recordsMarked();
        lastIndex     = recordsMarked.lastIndex();

        for (tmpSysQueryCompanyRange = CompanyRanges_DS.getFirst(); tmpSysQueryCompanyRange ; tmpSysQueryCompanyRange = CompanyRanges_DS.getNext() )
        {
            if (tmpSysQueryCompanyRange.IsCompanySelected == NoYes::Yes)
            {
                selectedCompanies = conIns(selectedCompanies, 1, tmpSysQueryCompanyRange.CompanyId);
            }
        }

        if (selectedCompanies)
        {
            lookup = SysTableLookup::newParameters(tableNum(DESVendorSpendReport),                      _formControl);
            lookup.addLookupfield(fieldNum(DESVendorSpendReport, AccountNum));
            lookup.addLookupfield(fieldNum(DESVendorSpendReport, Id));

            query = new Query();

            qbds = query.addDataSource(tableNum(DESVendorSpendReport));
            qbds.addRange(fieldNum(DESVendorSpendReport, id)).value(con2Str(selectedCompanies));
            lookup.parmQuery(query);

            lookup.performFormLookup();
          }
      else
      {
        SysLookup::lookupRange(_formControl, range, sysQueryForm.query());
      }
   }
   else
   {
     SysLookup::lookupRange(_formControl, range, sysQueryForm.query());
   }

}