Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Thursday, July 18, 2024

Iterate the container in D365 / AX 2012

 Hi,

static void HandlingContainerJob(Args _args)
{
    container contain;
    int i;
    str containstr;
    ;
    contain = ["DataAt1stPosition","DataAt2ndPosition"]; //Data will be inserted at position 1 and 2
    contain = Conins(contain,3,"DataAt3rdtPosition","DataAt4thPosition"); // from 3rd position onward
    contain = conins(contain,5,"DataAt5thPosition"); // now the data inserted in 5th position
    //or use this technique
 
    info (strFmt("Length of the container: %1", conLen(contain)));
    for (i=1; i <= conLen(contain); i++)
    {
        info (strFmt("container value %1 is %2", i, conPeek(contain, i)));
    }

}

Friday, May 10, 2024

How to invoke and iterate List as Contract methods in AX 2012/ D365

Hi,

Public void performContractIterate(ClassContainsListAsContract    _ListCarryClass)
{
List contractFieldList = new List(Types::Class);
ResResourceCategoryDataContract    resourceCategoryDataContract =  new ResResourceCategoryDataContract();
contractFieldList = _ListCarryClass.parmCustomFields();
/*
// List Iterator are not recorded for mutiTier data flow example integrations with other Apps like PowerApps or APIs
ListIterator        literator = new ListIterator(contractFieldList );
while (literator.more())
{
resourceCategoryDataContract= literator.value();
if(resourceCategoryDataContract.parmId() == 1 )
{
resourceCategoryId = resourceCategoryDataContract.parmValue();
}
literator.next();
}
*/
//Traverse the same _ListCarryClass using an enumerator
ListEnumerator   enumerator = contractFieldList .getEnumerator();
while(enumerator.moveNext())
{
resourceCategoryDataContract= enumerator.current();
switch (resourceCategoryDataContract.parmId())
{
case 1:
resourceCategoryId = resourceCategoryDataContract.parmValue();
break;
}
}
//<Perform your action based on the iterator value fetched>
}
_________________________________________________________________________________

Similar example.

DimensionValueService service = new DimensionValueService();
DimensionContract dimensionContract = new DimensionContract();
DimensionValueContract dimensionValueContract;
DimensionValue dimensionValue;
List dimensionValueContractList;
ListIterator contractorIterator;
 
;
  
dimensionContract.parmDimensionName(#DimName);
dimensionValueContractList = service.getDimensionValues(dimensionContract);
contractorIterator = new ListIterator(dimensionValueContractList);
ListEnumerator contractorEnumerator = dimensionValueContractList.getEnumerator();
    
    while(contractorEnumerator.moveNext())
    {
        dimensionValueContract = contractorEnumerator.current();
        dimensionValue = dimensionValueContract.parmValue();
        {
            info(strFmt("%1", dimensionValue));
        }
    }

Regards,

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...