Wednesday, July 31, 2019

How to disable New button in Action Pane on a Form


In the screenshot attached the actionpane "New" button is disabled. This can be done by changing form datasource property (Allow Create) which is shown in the below screenshot.







Friday, July 26, 2019

Disable users in AX using Sql Query


Open SSMS> New Query> Copy paste and run the query


update USERINFO SET ENABLE=0
where NAME in ('Uma Shankar')



You can disable multiple users by passing comma separated user names in the where condition.


Thanks,
Uma

Thursday, July 25, 2019

How to restrict filter on a form field using (RangeStatus::Locked) X++




Whatever date is chosen in the From Date filter only that date data should display on form. And on the form field a user cannot apply filter. This can be done by setting (RangeStatus::Locked) in x++. e.g.




Tuesday, July 23, 2019

How to get cost price of an Item based on Warehouse X++

public  real  GetCostPrice(ItemId _itemId, InventLocationId _inventLocationId)
    {
        InventDimParm inventDimParm;
        InventOnHand inventOnHand;
        InventSum inventSum;
        InventDim inventDim;
        ;

        select firstOnly1 inventSum where inventSum.ItemId == _itemId;
       
        //inventDim.InventSiteId = "SiteId";
        inventDim.InventLocationId = _inventLocationId;
        inventDimParm.initFromInventDim(inventDim);
        inventOnHand = InventOnHand::newItemDim(inventSum.ItemId, inventDim, inventDimParm);
        return inventOnHand.costPricePcs();
       // info(strfmt("%1", inventOnHand.costPricePcs()));
    }

Thanks
Uma

Get OnHand Stock value using Warehouse, Date and ItemId using X++

 public real GetOnHandStock(InventLocationId _warehouse,TransDate _transDate,Itemid _itemid)
    {
        InventDim                   inventDim;
        InventDimParm               inventDimParm;
        InventLocation              inventLocation;
        InventSumDatePhysicalDim    inventSumDatePhysicalDim;
        real                        OnhandQty;
        inventLocation              = InventLocation::find(_warehouse);
        inventDim.wMSLocationId     =inventLocation.WMSLocationIdDefaultReceipt;
        inventDim.InventLocationId  = inventLocation.InventLocationId;
        inventDim.InventSiteId      =inventLocation.InventSiteId;
        inventDim                   = InventDim::findOrCreate(inventDim);
        inventDimParm.initFromInventDim(inventDim);
        OnhandQty                    =    InventSumDatePhysicalDim::onHandQty(_transDate,_itemid,inventDim,inventDimParm);
        return OnhandQty;
    }

How Get Item Group Name (ItemGroupName) of an ItemId using x++

Get Item Group Name (ItemGroupName) of an ItemId using x++

class ItemGroupName
{  
    public static void main(Args _args)
    {     
        InventItemGroupItem                 inventItemGroupItem;
        inventItemGroupItem=InventItemGroupItem::findByItemIdLegalEntity('256473');
    // 256473 is Item Number
        info(strFmt("%1", inventItemGroupItem));
    }
}


Thanks
Uma

Thursday, July 18, 2019

How to Get Start Date and End Date from a Date (SystemDateGet())

How to  Get Start Date and End Date from a Date

utcDateTime fromDateTime,toDateTime;

fromDateTime= DateTimeUtil::newDateTime((DateStartMth(SystemDateGet())),str2time("00:00:00.000 AM"),DateTimeUtil::getUserPreferredTimeZone());


    toDateTime= DateTimeUtil::newDateTime((endmth(SystemDateGet())),str2time("23:59:59.000 PM"),DateTimeUtil::getUserPreferredTimeZone());

You can build a date range where fromDateTime is starting date of a month and toDateTime is ending date of a month.

Thanks
Uma

Get Enum Id and Enum Value in D365FO using SQL and X++

 Below is the sql get enum id and enum value of a enum in D365 F&O using sql. SELECT   enumidtable . NAME           'Enum Name' ...