Alfasith AX

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

Wednesday, April 24, 2024

How find size of recordsortedlist in D365/AX 2012

Hi,


This is the continuity of the previous article where we are now getting the size of recordsortedlist .


if(recordsortedlist.len() >1)
{
    print("Given recordsortedlist is bigger than 1");
}

Thanks,

How find size of List in D365/AX 2012

Hi,

public int listLengthCounter(List list)
{
Enumerator enumerator;
int length = 0;
;
enumerator = list.getEnumerator();
while(enumerator.moveNext())
{
length++;
}
return length;
}

But List has such a direct funtion


 if (list.elements() > 1) 
    { 
        print "It has has more than 1 elements"; 
    } 

Thanks

Monday, April 8, 2024

FileNameSplit() to slip the Directory, file name and extension in D365 FnO

 Hi,


    /// <summary>
    /// Validate the Fileformat
    /// </summary>
    /// <param name = "filepath">FilePath</param>
    /// <returns>Boolean</returns>
    public boolean validateFileExtension(str filepath)
    {
        str         actualFileName, fileExtension, actualFilePath;
        boolean     ok = true;
 
        [actualFilePath,actualFileName, fileExtension] = fileNameSplit(filePath);
 
        ok = strScan(actualFileName,allowedFileNameFormat,1,strLen(actualFileName));
        if(!ok)
        {
            Error("@SUNR:FileDoesntExisit");
        }
 
        return ok;
    }


Regards,


Wednesday, February 28, 2024

Dimension Lookup for both standard and Custom dimension in D365

Hi,


 /// <summary>

    /// Provides the look-up interaction for the individual dimension value lookup controls.

    /// </summary>

    /// <param name="_dimensionValueControl">

    /// The <c>FormStringControl</c> enumeration value that triggers this event.

    /// </param>

    /// <param name="_localizedName">

    /// The localized dimension attribute name

    /// </param>

    /// <param name="_promptErrorMessage">

    /// Whether prompt the error message if the dimension type is empty.

    /// </param>

    public static void dimensionValueLookup(

        FormStringControl   _dimensionValueControl,

        Name                _localizedName,

        boolean             _promptErrorMessage = false)

    {

        Query                   query = new Query();

        SysTableLookup          sysTableLookup;

        QueryBuildDataSource    qbds;


        DimensionAttribute      dimensionAttribute;

        RecId                   dimensionAttributeId;

        DataAreaId              dataAreaId = curext();


        if (_localizedName)

        {

            dimensionAttribute      = DimensionAttribute::findByLocalizedName(_localizedName, false, currentUserLanguage());

            dimensionAttributeId    = dimensionAttribute.RecId;

        }


        if (dimensionAttributeId)

        {

            sysTableLookup = SysTableLookup::newParameters(DimensionCache::instance().dimensionAttributeBackingTable(dimensionAttributeId), _dimensionValueControl);


            sysTableLookup.addLookupfield(dimensionAttribute.ValueAttribute);

            LedgerDimensionTranslationLookupHelper::addLookupTranslation(sysTableLookup, dimensionAttributeId);

            sysTableLookup.addSelectionField(dimensionAttribute.NameAttribute);


            changeCompany(dataAreaId)

            {

                qbds = query.addDataSource(DimensionCache::instance().dimensionAttributeBackingTable(dimensionAttributeId));

                qbds.addOrderByField(DimensionCache::instance().dimensionAttributeValueField(dimensionAttributeId));

                DimensionAttribute::restrictQueryToCategorizedValues(qbds, dimensionAttributeId);

            }


            sysTableLookup.parmQuery(query);

            sysTableLookup.performFormLookup();

        }

        else if (_promptErrorMessage)

        {

            //Please choose a value for "Dimension type" first!

            checkFailed("@GLS100015");

        }

    }


Regards


Tuesday, February 27, 2024

How to get enumValue from enumID in D365 (using SQl)

 Hi,


SELECT ENUMVALUETABLE.ENUMID, ENUMVALUETABLE.ENUMVALUE, ENUMVALUETABLE.NAME 

FROM ENUMVALUETABLE

INNER JOIN ENUMIDTABLE ON ENUMIDTABLE.ID = ENUMVALUETABLE.ENUMID

where ENUMIDTABLE.NAME = 'ProjOrigin'


Regards,

How find size of recordsortedlist in D365/AX 2012

Hi, This is the continuity of the previous article where we are now getting the size of recordsortedlist . if(recordsortedlist.len() >1) ...