Search your query

Thursday, January 26, 2023

Place various No. of Decimal for Unit Price or Purchase price value, Based on the Legal Entity


Here we are taking the example of Purchase order and we required No of decimals into 4 decimal places for Purchase price for particular Legal Entity - "USMF". Other legal entities are based EDT decimals.

Example: X++ code to display only 4 decimals for particular company:

[ExtensionOf(formStr(PurchTable))]

internal final class PurchTableTFPayrollForm_Extension

{

    [Hookable(false)]

    public void init()

    {

        FormRun callerForm;

        FormRealControl purchPriceField;

        next init();

        if (curExt() == "USMF")

        {

            purchPriceField = this.design().controlName("PurchLine_PurchPriceGrid");

            purchPriceField.noOfDecimals(4);

        }

    }

}


Wednesday, January 25, 2023

Export and Import Model file using Powershell Command

> Open Powershell as Admin

> Enter cd\

> type cd C:\AosService\PackagesLocalDirectory\bin

or

> type cd K:\AosService\PackagesLocalDirectory\bin

and then type below code for EXPORT:

C:\AosService\PackagesLocalDirectory\bin> .\ModelUtil.exe -export -metadatastorepath=C:\AosService\PackagesLocalDirectory -modelname="MyCreatedModel.axmodel" -outputpath=C:\temp\myModel 

** (myModel is new custom folder)


and type this below code for IMPORT:

K:\AosService\PackagesLocalDirectory\bin>.\ModelUtil.exe -import -metadatastorepath=K:\AOSService\PackagesLocalDirectory -file=C:\temp\myModel\MyCreatedModel.axmodel

Fetch and Display Dimension Description (Name) based on Dimension Id:


Create class for display method.

[ExtensionOf(tableStr(TableNameHere!))]

final Public class TableNameHere!_Extension

{

    [SysClientCacheDataMethodAttribute(true)]

    display public static Name displayDepartmentDimensionDescription(TableNameHere! _this)

    {

        DimensionAttributeValueSetStorage   dimStorage;

        DimensionAttribute                  dimAttr;

        DimensionAttributeValue             dimAttrValue;

        Name                                dimDescription;

       

        int i;

        DictTable                   dictTable;

        Common                      common;

 

        dimStorage = DimensionAttributeValueSetStorage::find(_this.DefaultDimension);

 

        for (i= 1 ; i<= dimStorage.elements() ; i++)

        {

            if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")

            {

                // get attribute select here.

                select firstonly dimAttrValue

                      where dimAttrValue.RecId == dimStorage.getValueByIndex(i)

                 join dimAttr

                        where dimAttr.RecId == dimAttrValue.DimensionAttribute;

 

                if (dimAttr && dimAttrValue)

                {

                    dictTable = new DictTable(dimAttr.BackingEntityType);

                    common = dictTable.makeRecord();

 

                    if (common.TableId)

                    {

                        select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;

                        dimDescription = common.(dimAttr.NameAttribute);

                    }

                }

          

            }

        }

 

        return dimDescription;

    }