Search This Blog

Friday 20 July 2018

Deleting Usage Data in D365 For Finance and Operations

Select the Settings button on the top right corner of your screen and then select user options like this.










A new screen will open where select the usage data like this.












A new form will open where u can see the usage data in different types and areas. you can delete all usage data or specific usage data as well.

In my case, I have selected form selection and deleted the usage data related to the forms.









Now I will select the record from the form selection tab and click delete and then the framework will delete the usage data related to that specific form.

Note as mentioned earlier we can delete all usage or usage data specific to particular forms or area as well.












That's all feel free to comment if you have any questions.

Thanks,
Zahid

Tuesday 10 July 2018

what should be the best DataSource type on Data Entity in Dynamics D365 for Operations

Below is the link that contains the discussion on which type of DataSource on DataEntity is good in which scenario:

Feel free to post if you guys have any questions.

https://community.dynamics.com/365/financeandoperations/f/765/p/286025/822134#822134

Thanks,
Zahid


Friday 1 June 2018

Get Financial Dimension using default dimension through x++ code and Sql in Dynamics AX #D365forOps


Below is the X++ code snippet for getting the Financial Dimensions using Default Dimension by using X++ code:

private str getFinancialDimensionName(Name _dimAttrName, DimensionDefault _defaultDimension)
    {
        DimensionAttribute dimAttr;
        DimensionAttributeValueSetStorage dimStorage;
        DimensionAttributeValue     dimAttrValue;
        Common                      common;
        DictTable                   dictTable;

        select firstOnly dimAttr where dimAttr.Name == _dimAttrName;
        if(dimAttr)
        {
            dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimension);

            select firstonly dimAttrValue
            where dimAttrValue.RecId == dimStorage.getValueByDimensionAttribute(dimAttr.recID)
            join dimAttr
            where dimAttr.RecId == dimAttrValue.DimensionAttribute;

            if (dimAttrValue)
            {
                dictTable = new DictTable(dimAttr.BackingEntityType);
                common = dictTable.makeRecord();

                if (common.TableId)
                {
                    select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
                    return common.(dimAttr.NameAttribute);
                }
            }
        }

        return "";
}

Where _dimAttrName = name of the dimension attribute like Department, Location etc

and _defaultDimension = value of the defaultDimension like value in DefaultDimension field of table HcmEmployment.

Below is the code snippet to get the department and location in Sql using default dimension.

select dimensionFinancialTag.description from  DefaultDimensionView
join dimensionFinancialTag on dimensionFinancialTag.VALUE = DefaultDimensionView.DISPLAYVALUE
    where DefaultDimensionView.DefaultDimension = 5637144783
      and DefaultDimensionView.Name = 'Location' 


select DisplayValue, dimAttributeOMDepartment.NAME from defaultDimensionView
 join dimAttributeOMDepartment
            on dimAttributeOMDepartment.Value = defaultDimensionView.DisplayValue
        where defaultDimensionView.DefaultDimension = 5637144783

            and defaultDimensionView.name = 'Department'

For Any Question feel free to Comment.

Thanks,
Zahid

Thursday 10 May 2018

Renaming Database Name using Query in SQL Server

Sometimes if we try to rename the database in our development or any other environment we got the error message that this database is in use by other process and we cant rename it.

So first we need to check if any user is not using that database and try to rename it. If still we got the same error then might be some services using that database.

Instead of investing time to investigate which service is causing the issue to rename the database you can simply write the below query to rename your database.

ALTER DATABASE oldatabasename SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

ALTER DATABASE olddatabasename MODIFY NAME = newdatabasename

ALTER DATABASE newdatabasename SET MULTI_USER WITH ROLLBACK IMMEDIATE;


Thanks,
Zahid

Monday 30 April 2018

Virtual Fields in Data Entity in Microsoft Dynamics 365 For Operations

Some times we need to populate fields on Data Entity based on some calculated X++ logic instead of binding them directly from table.

To do this below are the some simple steps.

1. right click your fields node of your data entity and than select the string Unmapped field.














note: you can select other type of umapped field if your field is not string.

2. After that go to the properties of that field set the name , label , extended data type and is computed field to no.

























After that right click your data entity and than override the postLoad() method.

and in that postload method you can write your X++ logic to populate that field.













Now after that once you rebuild your code and try to export data entity you will see this field will be populated in data entity.

Note: Data entities are saved as view on back end in sql and the main drawback of using virtual field is that you can see them in sql.You can only see when you use that entity with in Dynamics Domain.

Thanks,
Zahid


Friday 1 December 2017

Getting Dimension Values from Financial Dimensions in Dynamics 365 For Operations

I got one tasks of report development in which I have to show the Financal Dimension and its Dimension Value in a lookup on report parameter.

To do this the one I have to grab all the Dimension Values against the Financial Dimension to show in a lookup.

Below is the navigation for Financial Dimension Form in D365:

General Ledger -> Chart of Accounts -> Dimension -> Financial Dimensions.


















The form for Financial Dimension is.











As you can see in the above image there is a dimension value button when you click on it a new form will open containing all of the dimensions against that selected Financial Dimension.














So the question is how can we get the Dimension Values based Financial Dimension by using query.

Below is the code for you:

class RunnableClass1
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {   
        DimensionAttribute              dimAttr;
        DimensionAttributeViewContract  dimAttrViewContract;
        Query                           q;
        QueryRun                        qR;
        QueryBuildDataSource            qbds;
        Common                          common;

        dimAttr = DimensionAttribute::findByName("Department");


        dimAttrViewContract =  DimensionAttribute::getViewContract(dimAttr.RecId);

        q = new Query();

        changecompany (dimAttr.company())
        {
            qbds = q.addDataSource(dimAttrViewContract.parmViewId());
            qbds.addSortField(dimAttrViewContract.parmValueFieldId(),SortOrder::Ascending);

            // Apply ranges on language ID fields.
            DimensionAttribute::addTranslViewRangesToBackingEntityQuery(dimAttr.RecId, qbds);

            if (DimensionCache::instance().dimensionAttributeHasCategorization(dimAttr.RecId))
            {
                if (dimAttr.Type == DimensionAttributeType::MainAccount)
                {
                    qbds.addRange(dimAttrViewContract.parmCategoryFieldId()).value(queryValue(LedgerChartOfAccounts::current()));
                }
                else if (dimAttr.Type == DimensionAttributeType::CustomList)
                {
                    qbds = qbds.addDataSource(tablenum(DimensionAttributeDirCategory), 'DimAttDirCat');
                    qbds.relations(true);
                    qbds.joinMode(JoinMode::InnerJoin);
                    qbds.fetchMode(QueryFetchMode::One2One);
                    qbds.addLink(dimAttrViewContract.parmCategoryFieldId(), fieldnum(DimensionAttributeDirCategory, DirCategory));
                    qbds.addRange(fieldnum(DimensionAttributeDirCategory, DimensionAttribute)).value(strfmt('%1', dimAttr.RecId));
                }
            }
        }

        qR = new QueryRun(q);
        while(qR.next())
        {
            common = qR.get(dimAttrViewContract.parmViewId());

            info(strFmt("%1 %2",common.getFieldValue(dimAttrViewContract.parmValueFieldName()), common.getFieldValue(dimAttrViewContract.parmNameFieldName())));
        }
    }

}

For more Details Below is the link:

https://community.dynamics.com/ax/b/hellodax/archive/2015/07/07/get-all-financial-dimension-value-and-description-from-dimensionattribute

Thanks,
Zahid

Thursday 30 November 2017

Open Table Browser in other than Dat Company in Dynamics 365 for Operations

Some time we want to open the table browser in other than DAT company in Dynamics 365 for operations.

To open table browser in other company below is the link that contains the full description:

https://community.dynamics.com/crm/b/microsoftdynamicscrmsolutions/archive/2016/01/25/open-table-browser-with-different-legal-entity-in-ax-7


Thanks,
Zahid.