Followers

16 January 2020

Ph number want like TELEPHONE (262) 444-8888 in ax


Ph number want like TELEPHONE (262) 444-8888 in ax :



        WarrantyClaimFormPartHeaderTmp.DealerDaytimePhone             = "("+ SubStr(WarrantyClaimTable.DealerDaytimePhone,1,3)+ ") "+SubStr(WarrantyClaimTable.DealerDaytimePhone,4,3)+ "-"+SubStr(WarrantyClaimTable.DealerDaytimePhone,7,4);

Find the physical date for item with site/warehouse combination through batch job in d365

Find the physical date for item  with site/warehouse combination through batch job in d365 :



class FirstReceiptDateItemWarehouseBatch  extends RunBaseBatch
{
    #DEFINE.CurrentVersion(1)
    #DEFINE.Version1(1)

    boolean canGoBatchJournal()
    {
        //true if the class is shown in the list of Journal types; otherwise, false.
        return true;
    }

    protected void new()
    {
        super();
    }

    public container pack()
    {
        //Serializes the current instance of the RunBase class.
        return [#CurrentVersion];
    }

    void run()
    {
        #OCCRetryCount
        ;
        try
        {
            this.insertFirstReceiptDate();
        }
        catch (Exception::Deadlock)
        {
            retry;
        }
        catch (Exception::UpdateConflict)
        {
            if (appl.ttsLevel() == 0)
            {
                if (xSession::currentRetryCount() >= #RetryNum)
                {
                    throw Exception::UpdateConflictNotRecovered;
                }
                else
                {
                    retry;
                }
            }
            else
            {
                throw Exception::UpdateConflict;
            }
        }
    }

    public boolean runsImpersonated()
    {
        return true;
    }

    public boolean unpack(container packedClass)
    {
        //Deserializes the packedClass parameter value to an instance of the RunBase class.
        boolean         isSuccessful;
        Version         version = RunBase::getVersion(packedClass);
        ;

        switch (version)
        {
            case #CurrentVersion:
            {
                [version] = packedClass;
                isSuccessful = true;
                break;
            }
         
        default :
            return false;
        }

        return isSuccessful;
    }

    server static FirstReceiptDateItemWarehouseBatch construct()
    {
        return new FirstReceiptDateItemWarehouseBatch();
    }

    client server static ClassDescription description()
    {
        return "ProductFirstReceiptDate";
    }

    public static void main(Args args)
    {
        FirstReceiptDateItemWarehouseBatch firstReceiptBatch = FirstReceiptDateItemWarehouseBatch::construct();

        if (firstReceiptBatch.prompt())
        {
            firstReceiptBatch.runOperation();
        }
    }


    public void insertFirstReceiptDate()
    {
        ItemSiteLocationTmp      usvItemSiteLocationTmp;
        ProductFirstReceiptDate  usvProductFirstReceiptDate;
        InventTable                 inventTable;
        InventLocation              inventLocation;

        InventTrans                 inventTrans;
        InventTransOrigin           inventTransOrigin;
        InventDim                   inventDim;
        FirstReceiptDate         usvFirstReceiptDate;
        Counter                     cntProcessed;
        Counter                     cntInserted;

        setprefix(USVFirstReceiptDateItemWarehouseBatch::description());

       

        insert_recordset ItemSiteLocationTmp (ItemId, InventSiteId, InventLocationId)
        select ItemId from inventTrans                       // process only if Item transactions
            group by inventTrans.ItemId, inventDim.InventSiteId, inventDim.inventLocationId
                where inventTrans.StatusReceipt                 == StatusReceipt::Purchased
                &&    inventTrans.DatePhysical                  != dateNull()  // must have date
            join InventSiteId, InventLocationId from inventDim  // process only if transactions in Site/Warehouse
                where inventDim.inventDimId                     == inventTrans.inventDimId
                &&    inventDim.InventSiteId                    != ''
                &&    inventDim.inventLocationId                != ''
            exists join inventTransOrigin                    // process only if these types exist
                where inventTransOrigin.RecId                   == inventTrans.InventTransOrigin
                &&   (inventTransOrigin.ReferenceCategory       == InventTransType::TransferOrderReceive
                   || inventTransOrigin.ReferenceCategory       == InventTransType::InventTransaction
                   || inventTransOrigin.ReferenceCategory       == InventTransType::InventCounting
                   || inventTransOrigin.ReferenceCategory       == InventTransType::WHSWork
                   || inventTransOrigin.ReferenceCategory       == InventTransType::Purch);

        ttscommit;

        info(strfmt("@SYS76766", "@SYS74037", ItemSiteLocationTmp.RowCount()));

        // process combinations (eliminating certain combinations)
        while select ItemSiteLocationTmp
            exists join inventTable
                where inventTable.ItemId                        == usvItemSiteLocationTmp.ItemId
                &&    inventTable.ItemType                      == ItemType::Item   // Items only
            exists join inventLocation
                where inventLocation.InventLocationType         == InventLocationType::Standard  // Default warehouses only
                &&    inventLocation.InventSiteId               == usvItemSiteLocationTmp.InventSiteId
                &&    inventLocation.InventLocationId           == ItemSiteLocationTmp.InventLocationId
            notexists join usvProductFirstReceiptDate        // process only if no FirstReceipt record
                where ProductFirstReceiptDate.ItemId         == ItemSiteLocationTmp.ItemId
                &&    ProductFirstReceiptDate.SiteId         == ItemSiteLocationTmp.InventSiteId
                &&    ProductFirstReceiptDate.WarehouseId    == ItemSiteLocationTmp.InventLocationId
        {
            cntprocessed++;
            usvFirstReceiptDate = dateNull();

            // find earliest DatePhysical for Item/Site/Warehouse
            while select DatePhysical from inventTrans
                order by DatePhysical asc
                    where inventTrans.ItemId                    == usvItemSiteLocationTmp.ItemId
                    &&    inventTrans.StatusReceipt             == StatusReceipt::Purchased
                    &&    inventTrans.DatePhysical             != dateNull()  // must have date

                join ReferenceCategory, ReferenceId, RecId from inventTransOrigin  //  process only if these types exist
                    where inventTransOrigin.RecId               == inventTrans.InventTransOrigin
                    &&   (inventTransOrigin.ReferenceCategory   == InventTransType::TransferOrderReceive
                       || inventTransOrigin.ReferenceCategory   == InventTransType::InventTransaction
                       || inventTransOrigin.ReferenceCategory   == InventTransType::InventCounting
                       || inventTransOrigin.ReferenceCategory   == InventTransType::WHSWork
                       || inventTransOrigin.ReferenceCategory   == InventTransType::Purch)

                join RecId from inventDim                    // process only if transactions in Site/Warehouse
                    where inventDim.inventDimId                 == inventTrans.inventDimId
                    &&    inventDim.InventSiteId                == ItemSiteLocationTmp.InventSiteId
                    &&    inventDim.inventLocationId            == ItemSiteLocationTmp.InventLocationId
            {
                if (FirstReceiptDate != dateNull())
                {
                    break;
                }

                if (inventTransOrigin.ReferenceCategory  == InventTransType::WHSWork)
                {
                    WHSWorkTable    whsWorkTable;
                    select firstonly RecId from whsWorkTable
                        where whsWorkTable.WorkId           == inventTransOrigin.ReferenceId
                        &&    whsWorkTable.WorkStatus       == WHSWorkStatus::Closed
                        &&   (whsWorkTable.WorkTransType    == WHSWorkTransType::Purch
                           || whsWorkTable.WorkTransType    == WHSWorkTransType::TransferReceipt);

                    if (whsWorkTable.RecId)
                    {
                        usvFirstReceiptDate = inventTrans.DatePhysical;
                    }
                }
                else
                {
                    usvFirstReceiptDate = inventTrans.DatePhysical;
                }
            }

            if (FirstReceiptDate != dateNull())
            {
                ProductFirstReceiptDate  ProductFirstReceiptDateInsert;

                ProductFirstReceiptDateInsert.ItemId             = ItemSiteLocationTmp.ItemId;
                ProductFirstReceiptDateInsert.SiteId             = ItemSiteLocationTmp.InventSiteId;
                ProductFirstReceiptDateInsert.WarehouseId        = ItemSiteLocationTmp.InventLocationId;
                ProductFirstReceiptDateInsert.FirstReceiptDate   = FirstReceiptDate;
                ProductFirstReceiptDateInsert.insert();
                cntInserted++;
            }
        }

        info(strfmt("@SYS76766", "@SYS103900", cntProcessed));
        info(strfmt("@SYS76766", "@SYS77068", cntInserted));
    }

}

15 August 2019

Barcode in ax

Code for barcode in ax :


 public BarCodeString getBarcode(str _barCodeText)
    {
         

        BarCodeString   barCodeString;
        Barcode         barcode;
        barcode = Barcode::construct(BarcodeType::Code128);

        barcode.string(true, _barCodeText);
        barcode.encode();
        barCodeString = barcode.barcodeStr();
     
        return barCodeString;
       
    }

14 August 2019

Create the macro in AX

Create the macro in AX :


> Create macro and double click on micro
Ex: MicroName
> Assign micro

Ex : #define.fieldname('filedname')

     #define.TireWarr('TireWarr')

>Assign micro where you need in class

ex: #microname


Excute the runnable class in D365

Excute the runnable class in D365 :


https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=Classname


Ex:

https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=ShowInvoicedOrderCount

19 September 2018

Update the fields values from one field to another field while click the menuitem button in form AX2012

Update the fields values from one field to another field while click the menu item button in form AX2012 :

1) Create the class
2) Create menu item (Action) and add the created class for menu item.
3) Created menu item attached in form menu item button.
4) override the menu item button for refresh the data source.

Ex Code:

Class:

class PMCopyEquipmenttoCLR
{

}

public void CopyEquipmenttoCLR(Args _args)
{
    PMSubJobLotLevelLines    pmSubJobLotLevelLines, pmSubJobLotLevelLinesloc;
    pmSubJobLotLevelLinesloc = _args.record();

    update_recordset pmSubJobLotLevelLines
              setting Additional4 = pmSubJobLotLevelLines.EquipmentNumber
                 where pmSubJobLotLevelLines.Selected == NoYes::Yes
                        && pmSubJobLotLevelLines.SubJobId == pmSubJobLotLevelLinesloc.SubJobId
                        && pmSubJobLotLevelLines.EquipmentNumber!= "";
}

public static void main(Args _args)
{
    PMSubJobLotLevelLines       pmSubJobLotLevelLines;
    PMCopyEquipmenttoCLR        pmCopyEquipmenttoCLR;
    FormDataSource              PMSubJobLotLevelLines_ds;

    pmCopyEquipmenttoCLR        = new PMCopyEquipmenttoCLR();

    if (_args.record() && _args.record().TableId == tableNum(PMSubJobLotLevelLines))
    {
        pmSubJobLotLevelLines          = _args.record();
        PMSubJobLotLevelLines_ds       = pmSubJobLotLevelLines.dataSource();
        pmCopyEquipmenttoCLR.CopyEquipmenttoCLR(_args);
    }
}


This is the class for menu item button clicked for update the fields from one to another column.

17 September 2018

Copy data from one field to another field in table for selected lines while button clicked in form in AX2012

Copy data from one field to another field in table for selected lines while button clicked in form in AX2012 :

Example Code:

void clicked()
{
    PMSubJobLotLevelLines   tPMSubJobLotLevelLines;
    tPMSubJobLotLevelLines = PMSubJobLotLevelLines_ds.getFirst();
    while (tPMSubJobLotLevelLines)
    {
        if (tPMSubJobLotLevelLines.Selected == NoYes::Yes)
        {
           
            ttsBegin;
            tPMSubJobLotLevelLines.Additional4 = tPMSubJobLotLevelLines.EquipmentNumber;
            tPMSubJobLotLevelLines.update();
            ttsCommit;
        }
            tPMSubJobLotLevelLines = PMSubJobLotLevelLines_ds.getNext();

    }
    super();

}