Monday 23 October 2017

creation of test case and running it sucessfully

Please create a new test case in class WHSPhysDimUOMScenarioTest   right click the test and click run


    /// <summary>
    /// Tests that when the isAnyPhysicalDimensionDifferentThanItemInventoryPhysicalDimension  is   called with a different
    /// Depth in inventory physical dimension unit of measure and physical dimension unit of measure,
    /// then the returned type will be true.
    /// </summary>
    [SysTestMethod]
    public void isPhysicalDimensionsDistinctThanInventoryDimension_DiffrentUOMFound_returnFalse()
    {
        WHSPhysDimUOM   WHSPhysDimUOM;
        boolean         ret = false;
       
        ttsbegin;
        // Arrange
        select forupdate item;
        item.grossDepth  = 10;
        item.grossHeight = 25;
        item.grossWidth  = 30;
        item.TaraWeight  = 10;
        item.NetWeight   = 20;
        item.doUpdate();
        WHSPhysDimUOM.UOM       = '';
        WHSPhysDimUOM.ItemId    = item.ItemId;
        WHSPhysDimUOM.Depth     = 10;
        WHSPhysDimUOM.Height    = 25;
        WHSPhysDimUOM.Width     = 30;
        WHSPhysDimUOM.Weight    = 30;
        WHSPhysDimUOM.doInsert();
        // Act
        ret = WHSPhysDimUOM.isAnyPhysicalDimensionDifferentThanItemInventoryPhysicalDimension();
        WHSPhysDimUOM.reread();
        // Assert
        this.assertEquals(ret, false, 'The item inventory physical dimension is different for the physical dimesnsion.');
        ttsabort;
    }

Saturday 21 October 2017

xppcAgent in d365

when ever we do build in D365 then normally it takes minutes to load the form in AX .

we can some thing to make it work faster

1.disable best practice check

2.We should kill Xppc Agent in task manager.



normally when we do build this starts in work and as build gets over  please go to the task manager and kill the specified task.

then the form will get loaded faster

but please make sure you do this after build is over other wise build will not het completed.


useful links for AX 7

catch the tts level in the catch


Sometimes when ever we are getting some error regarding the ttscommit level aborted , there we need to catch the ttsimbalance in the try catch.

catch (Exception::UpdateConflict)
        {
            if (appl.ttsLevel() != 0)
            {
                throw Exception::UpdateConflict;
            }
            this.myLogMethod();
        }


disable the form datasource from the class.

We can easily disable the form datasource from the class.

Practically there should be no code in the form except calling the methods all the codes should ne on form or tables.

lets have this code in form datasource active and modified method :

[DataSource]
    class WHSPhysDimUOM
    {
        public int active()
        {
            int ret = super();

            whsPhysDimUOMForm.setAllowEditPhysicalDimUOMDataSourc(WHSPhysDimUOM_ds);
                     
            return ret;
        }
        [DataField]
        class UOM
        {
            public void modified()
            {
                super();
                whsPhysDimUOMForm.setAllowEditPhysicalDimUOMDataSource(WHSPhysDimUOM_ds);
            }
        }
    }


Now go to the class write the code as :

    /// <summary>
    /// Sets the allow edit property for the passed <c>WHSPhysDimUOM</c> form data source.
    /// The passed data source must be <c>WHSPhysDimUOM</c>.
    /// </summary>
    public void setAllowEditPhysicalDimUOMDataSource(FormDataSource _formDataSource)
    {
        if (_formDataSource.cursor() is WHSPhysDimUOM)
        {
            WHSPhysDimUOM physDimUOM = _formDataSource.cursor();
            _formDataSource.allowEdit(!physDimUOM.isUnitSameAsItemInventoryUnit());
        }
        else
        {
            throw error(Error::wrongUseOfFunction(funcName()));
        }
    }



write the code in the table  :


    /// <summary>
    /// Checks if the unit is the same as the item's inventory unit, if the item is set.
    /// </summary>
    /// <returns>true, if the unit is the same as the item's inventory unit and the item is set; otherwise false.</returns>
    public boolean isUnitSameAsItemInventoryUnit()
    {
        return (this.ItemId
                && this.UOM == InventTableModule::find(this.ItemId, ModuleInventPurchSales::Invent).UnitId);
    }

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...