Blog

Name is Anant Dubey and the intent to create this blog is to discuss the problems and issues that developer face in the dynamics AX development and to share the new things that come up with the new version of AX.

Tuesday, September 21, 2021

Convert Amount in words in d365 India

 static void amount2words(Args _args)

{
real amount = 1011.05;
int numOfPennies = frac(amount)*100 mod 100;
int test = real2int(round(amount,0));
int paise;
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, lakhs, crores, millions, billions;
str 40 textpaise;
int tmpnumofpennies;
int temp;
str 200 returntxt;

int checkPower(int _test, int _power)
{
int 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 1000000000 :
{
returntxt = returntxt + ‘ ‘ + billions;
_test = _test MOD 1000000000;
break;
}
case 10000000 :
{
returntxt = returntxt + ‘ ‘ + crores;
_test = _test MOD 10000000;
break;
}
case 100000 :
{
returntxt = returntxt + ‘ ‘ + lakhs;
_test = _test MOD 100000;
break;
}
case 1000 :
{
returntxt = returntxt + ‘ ‘ + thousands;
_test = _test MOD 1000;
break;
}
case 100 :
{
returntxt = returntxt + ‘ ‘ + hundreds;
_test = _test MOD 100;
break;
}
}
}
return _test;
}

ones[1] = “@SYS26620”;
ones[2] = “@SYS26621”;
ones[3] = “@SYS26622”;
ones[4] = “@SYS26626”;
ones[5] = “@SYS26627”;
ones[6] = “@SYS26628”;
ones[7] = “@SYS26629”;
ones[8] = “@SYS26630”;
ones[9] = “@SYS26631”;
ones[10] = “@SYS26632”;
ones[11] = “@SYS26633”;
ones[12] = “@SYS26634”;
ones[13] = “@SYS26635”;
ones[14] = “@SYS26636”;
ones[15] = “@SYS26637”;
ones[16] = “@SYS26638”;
ones[17] = “@SYS26639”;
ones[18] = “@SYS26640”;
ones[19] = “@SYS26641”;

tenths[1] = ‘Not used’;
tenths[2] = “@SYS26643”;
tenths[3] = “@SYS26644”;
tenths[4] = “@SYS26645”;
tenths[5] = “@SYS26646”;
tenths[6] = “@SYS26647”;
tenths[7] = “@SYS26648”;
tenths[8] = “@SYS26649”;
tenths[9] = “@SYS26650”;

hundreds = “@SYS26651”;
thousands = “@SYS26652”;
lakhs = “Lakh”;
crores = “Crore”;
millions = “@SYS26653”;
billions = “@SYS26654”;
test = checkPower(test, 1000000000);
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 = test;
returntxt = returntxt + ‘ ‘ + ones[numOfTenths];
}
if (numOfPennies)
{
returntxt = returntxt + ‘ ‘ + “@SYS5534” + “\n\n”;
}
paise=numofPennies;
if(paise)
{
if(paise >=20)
{
numofTenths= paise DIV 10;
returntxt=returntxt + ‘ ‘+tenths[numofTenths];
numofTenths = numofTenths MOD 10;
paise=paise MOD 10;
}
if(paise >=1)
{
numOfTenths=paise;
returntxt=returntxt+ ‘ ‘+ones[numOfTenths];
}
returntxt=returntxt+” Paise”;
}

info(strFmt(“%1″,returntxt + ” Only”));
}

Sunday, September 19, 2021

Get Value from Multi-Select Control Or Get split value from a string in d365


public container SSI_createContainers()
{
List            list = new List(Types::String);
ListIterator    i;
    container       RecIds, Names;
RecId           id;

//Create Container for the RecIds, Names
list = Global::strSplit(SalesParameters.SSI_MainAccountId,”;”);

i = new ListIterator(list);
while(i.more())
{
id = MainAccount::findByMainAccountId(i.value()).RecId;
RecIds += id;
Names += i.value();
i.next();
}

return [RecIds, Names];

}


reference - https://stoneridgesoftware.com/how-to-create-multi-select-lookup-in-microsoft-dynamics-ax/


Link for multi select lookup on SSRS report - 

https://dynamicsaxinsight.wordpress.com/2014/12/12/ax-2012-multi-select-lookup-for-ssrs-report-dialog/


Thursday, September 16, 2021

Testing

 

private void AFZLookupDimension(FormStringControl _formStringControl, Name _dimensionName) { DimensionAttribute DimensionAttribute = DimensionAttribute::findByName(_dimensionName); Query query = new Query(); QueryBuildDataSource qbdsFinancialTag,qbdsDirCategory; QueryBuildRange qbr; SysTableLookup SysTableLookup = SysTableLookup::newParameters(tableNum(DimensionFinancialTag),_formStringControl); qbdsFinancialTag = query.addDataSource(tableNum(DimensionFinancialTag)); qbdsFinancialTag.addOrderByField(fieldNum(DimensionFinancialTag,Value),SortOrder::Ascending); qbdsDirCategory = qbdsFinancialTag.addDataSource(tableNum(DimensionAttributeDirCategory)); qbdsDirCategory.relations(false); qbdsDirCategory.addLink(fieldNum(DimensionFinancialTag,FinancialTagCategory),fieldNum(DimensionAttributeDirCategory,DirCategory)); qbr = qbdsDirCategory.addRange(fieldNum(DimensionAttributeDirCategory,DimensionAttribute)); qbr.value(queryValue(DimensionAttribute.RecId)); SysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag,Value)); SysTableLookup.addLookupfield(fieldNum(DimensionFinancialTag,Description)); SysTableLookup.addSelectionField(fieldNum(DimensionFinancialTag,Value)); SysTableLookup.parmQuery(query); SysTableLookup.performFormLookup(); }

Wednesday, September 15, 2021

Get Ledger Dimension in based on different values in d365

<> 

class AFZGlobalClass

{

    public static DimensionDynamicAccount   generateLedgerDimension(container    _conData, MainAccountNum _mainAccountId)

    {

        int hierarchyCount;

        int hierarchyIdx;

        RecId                   dimAttId_MainAccount;

        LedgerRecId            ledgerRecId;

        MainAccount mainAccount;

        RefRecId recordvalue;

        DimensionAttribute     dimensionAttribute;

        DimensionAttributeValue dimensionAttributeValue;

        DimensionSetSegmentName DimensionSet;

        DimensionStorage         dimStorage;

        LedgerAccountContract LedgerAccountContract = new LedgerAccountContract();

        DimensionAttributeValueContract  ValueContract;

        List   valueContracts = new List(Types::Class);

        dimensionAttributeValueCombination dimensionAttributeValueCombination;

        //CostCenter,Department,Worker ..etc..

        //container                  _conData =["142102","C","ADMIN"];;

        //mainAccount = MainAccount::findByMainAccountId('400301');

        mainAccount = MainAccount::findByMainAccountId(_mainAccountId);

        recordvalue = DimensionHierarchy::getAccountStructure(mainAccount.RecId,Ledger::current());

        hierarchyCount = DimensionHierarchy::getLevelCount(recordvalue);

        DimensionSet = DimensionHierarchyLevel::getDimensionHierarchyLevelNames(recordvalue);

        for(hierarchyIdx = 1;hierarchyIdx<=hierarchyCount;hierarchyIdx++)

        {

            if(hierarchyIdx == 1)

           continue;

            dimensionAttribute = DimensionAttribute::findByLocalizedName(DimensionSet[hierarchyIdx],false,"en-us");

            if(dimensionAttribute)

            {

                dimensionAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,conPeek(_conData,hierarchyIdx));


                if(dimensionAttributeValue)

                {

                    ValueContract = new DimensionAttributeValueContract();

                    ValueContract.parmName(dimensionAttribute.Name) ;

                    ValueContract.parmValue(dimensionAttributeValue.CachedDisplayValue);

                    valueContracts.addEnd(ValueContract);

                }

            }

        }

        LedgerAccountContract.parmMainAccount(_mainAccountId);

        LedgerAccountContract.parmValues(valueContracts);

        dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(LedgerAccountContract);

        dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());

        ledgerRecId = dimensionAttributeValueCombination.RecId;

        return ledgerRecId;

    }

}

</>


Reference link - https://www.linkedin.com/pulse/generate-financial-dimension-ledgerdimension-dynamics-yadav/
Thanks - Shashi kant Yadav

Wednesday, September 1, 2021

Deploy Package using RunBook using command prompt in d365

 

AXUpdateInstaller.exe generate -runbookid="Package-00130-runbook" -topologyfile="DefaultTopologyData.xml" -servicemodelfile="DefaultServiceModelData.xml" -runbookfile="Package-00130-runbook.xml"

AXUpdateInstaller.exe import -runbookfile=Package-00130-runbook.xml

AXUpdateInstaller.exe list

AXUpdateInstaller.exe execute -runbookid=Package-00130-runbook
-----------------------------------------------
above these are main commands to import pkg

link - http://d365technext.blogspot.com/2018/06/package-deployment-using-run-book.html

Deploy model wise All SSRS Reports in d365fo using powershell

For Model wise

C:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -Module MODELNAME -PackageInstallLocation "C:\AosService\PackagesLocalDirectory"


For Local environment

C:\Packages\Plugins\AxReportStartVmRoleStartupTask\DeployAllReportsToSSRS.ps1


For Azure environment

C:\AosService\PackagesLocalDirectory\Plugins\AxReportVmRoleStartupTask\DeployAllReportsToSSRS.ps1 -PackageInstallLocation “C:\AosService\PackagesLocalDirectory”



if required Run below command first - 

Set-ExecutionPolicy Unrestricted

Y