Thursday 15 May 2014

Bank Reconciliation

Why do we need bank reconciliation ?

https://www.youtube.com/watch?v=aeOOZdLTX0s - Bank reconciliation part 1

https://www.youtube.com/watch?v=1ucXpzjUajY - Bank reconciliation part 2

1. Internal Control.
2. We review cancel checks , we get opportunity to check any fraud had happend ...

Two Balances at end of each month.

i) bank statement from the bank
ii) balance as per books in company

if to are different, we find the items that cause the difference.
To come up with true cash balance , its not either bank statement or, balance in books.

Wednesday 14 May 2014

SSRS Report Links

If report design not opened in 2015 https://stackoverflow.com/questions/31581432/missing-microsoft-rdlc-report-designer-in-visual-studio

http://dineshspatel.blogspot.com/2010/11/mdx-basic.html
https://www.youtube.com/watch?v=WAO819-gkKw  - nice vedios on SSRS


http://community.dynamics.com/ax/b/axprodteamuk/archive/2011/04/15/dynamics-ax-2012-hands-on-labs.aspx
 - Important.


http://dynamicsaxgyan.wordpress.com/2012/05/15/display-barcode-in-ssrs-report-dynamics-ax-2012/

 - > Barcode in SSRS report

http://www.dynamics101.com/2014/01/using-controller-class-developing-ssrs-reports-microsoft- dynamics-ax-2012/  - How to change design for query based report , based on parameter 

Free text index

Full Text Index in Dynamics AX 2012 – X++


Friends,
Full text index supports to quickly query words that are embedded in the middle of a string field of a table. Well, this is a very nice enhancement to query on Database table fields for the developers who work with the latest vesion [Microsoft Dynamics AX 2012]
Good thing is we can use this Index on Memo fields and also Extended data type.
Let me explain with an example. Create a new table as shown below and add a new field of type string “Name” to it – On the field use EDT – Name. In the below example, my table Name is SR_FullTextExample.
Once you are done with your table, Go to FullTextIndex Node >> Right click and create a new FullTextIndex.
Rename it to NameFullTextIndex. Drag and drop Name field from the fields to the newly created index.
The table with index should look like below.
I have added some dummy records/data for testing purpose as shown below.
Now, let us see how to use this FullTextIndex for searching a field with the words.
Please Note: X++ select statements cannot use a full text index
A full text index can improve the speed of queries that search for words that are embedded in string and memo fields on tables. [MS help]
The QueryRange class has a rangeType method. You can direct a QueryRange object to use the full text index by passing the QueryRangeType::FullText enum value to the rangeType method. [MS help]
If the value you are searching for is a two word phrase with a space between the words, the system treats the space as a Boolean OR [MS Help]
Below job will help to search the strings with in a full string in the fields.
static void SR_FullTextQuery(Args _args)
{
    Query                   query;
    QueryBuildDataSource    qbds;
   
    QueryBuildRange         queryBuildRange;
    QueryRun                queryRun;
    SR_FullTextExample      sr_FullTextExample;

   
    query = new Query();
    qbds = query.addDataSource(tableNum(SR_FullTextExample));
    queryBuildRange = qbds.addRange(fieldNum(SR_FullTextExample, Name));

    queryBuildRange.rangeType(QueryRangeType::FullText);

    // The space character is treated as a Boolean OR.
    queryBuildRange.value(“Sreenath Kumar”);

    queryRun = new QueryRun(query);
    while (queryRun.next())
    {
        sr_FullTextExample = queryRun.get(tableNum(SR_FullTextExample));
        info(sr_FullTextExample.Name);
    }

}



As you can see, the results displayed is purely based on the search using ‘OR’ condition.
==============================================================

Example:
/*
   Two important rules for creating Full Text Indexes

[Technet]
TableGroup property.
    A table can have a full text index only if the TableGroup property
    is set to Main or Group on the table.

    A full text index can only be created on a table with RecId index.
    So make sure 'CreateRecIdIndex' property flag on table is set to Yes
*/

static void FullTextIndexesDemo()
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDatasource;
    QueryRun                queryRun;
    QueryBuildRange         queryRange;
    FullTextIndexesDemo     fullTextIndexes;

    queryBuildDatasource = query.addDataSource(tableNum(FullTextIndexesDemo));
    queryRange           = queryBuildDatasource.addRange(fieldNum(FullTextIndexesDemo, 
                 AxVersion));
    queryRange.rangeType(QueryRangeType::FullText);
    /*
    [Technet] Space characters are treated as implicit Boolean OR operators.
    There is a space character in the string parameter in call
    queryBRange4.value("dynamics 0");.
    */
    queryRange.value('dynamics 0');

    queryRun = new QueryRun(query);

    while (queryRun.next())
    {
        fullTextIndexes = queryRun.get(tableNum(FullTextIndexesDemo));
        Debug::printTab(DebugPrintTab::ActiveX, fullTextIndexes.AxVersion);
    }
}

Tuesday 6 May 2014

Code to find whether the role is assigned to User

How to find whether the role is assigned to User or not :


Class\SalesTableListPageInteraction\setButtonSell() method.

               while select User, SecurityRole from t1 
        join company from t2 where t2.id == t1.User
        join Name from t3 where t1.SecurityRole == t3.RecId &&
           t1.User == curUserId() &&         
           t2.company == curext()
          
    {
        if(t3.name == "Sales manager" && salestable.DocumentStatus == DocumentStatus::Confirmation)
            allowUpdate = false;
        else
            allowUpdate = true;
       // info(strFmt("%1,%2,%3",t1.User,t1.SecurityRole, t3.Name));
    }
   
    this.listPage().actionPaneControlEnabled(formControlStr(SalesTableListPage, EditButton),        allowUpdate);


Monday 5 May 2014

NEN - Financial Dimension Range



 

The task is to set range for finacial dimension .

Issue:
1. Get all the users who are assigned to particular deparment dimension value 
2. To set range for Dimension ( department).
 ========================================================================

Explanation :

1. dimAttributeDep = DimensionAttribute::getAttributeByUnitType(DimensionUnitType::Department);

The above command gets "Department" in to string  "dimAttributeDep"

2. SysQuery::addDimensionAttributeRange(_query,

                                                queryDataSourceStr(PurchTableListPage, PurchaseTable),
                                                fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
                                                DimensionComponent::DimensionAttribute,
                                                filterDep,
                                                dimAttributeDep.Name);


The above command Sets range for  "Department" in financial Dimension . where filterDep holds the range value ( example 101 - for dimension Department. 


3. departmentRecIds = HcmWorker::getDepartmentRecIds(SysQueryRangeUtil::currentWorkerRecId());
            for (i=1;i<=conLen(departmentRecIds);i++)  // Code for this method is given in below table
            {
                OMOperatingUnit::numberOfWorkers(true, true, conPeek(departmentRecIds,i),DateTimeUtil::utcNow(),setWorkers);
            }
            if (setWorkers.elements() > 0)
            {
                setIterator = new SetIterator(setWorkers);
                setIterator.begin();
                while (setIterator.more())
                {
                   strWorkers += strFmt("%1,",setIterator.value());
}
 


 The above code gets the Workers assigned to particular Department - '101' for department For example. 

================================================================================================================

 



public void initializeQuery(Query _query)

{
worker = HcmWorker::find(SysQueryRangeUtil::currentWorkerRecId());
    if (!worker)
        throw error(strfmt('%1%2', CurUserId(),' has not been linked to any employee record.\nPlease contact you system administrator to rectify the problem.' ));

    filterDep = DirPerson::find(worker.Person).Filter; // filterDep – is assigned value and Range is applied for Department without any check of Filter we applied in front end
    if(filterDep)
    {
        dimAttributeDep = DimensionAttribute::getAttributeByUnitType(DimensionUnitType::Department);

        SysQuery::addDimensionAttributeRange(_query,
                                                queryDataSourceStr(PurchTableListPage, PurchaseTable),
                                                fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
                                                DimensionComponent::DimensionAttribute,
                                                filterDep,
                                                dimAttributeDep.Name);

}
-----------------------------------------------------------------------------------------------------------------


if (filterCreator == NoYes::Yes)
    {
        if (filterUseHome)
        {
            departmentRecIds = HcmWorker::getDepartmentRecIds(SysQueryRangeUtil::currentWorkerRecId());
            for (i=1;i<=conLen(departmentRecIds);i++)  // Code for this method is given in below table
            {
                OMOperatingUnit::numberOfWorkers(true, true, conPeek(departmentRecIds,i),DateTimeUtil::utcNow(),setWorkers);
            }
            if (setWorkers.elements() > 0)
            {
                setIterator = new SetIterator(setWorkers);
                setIterator.begin();
                while (setIterator.more())
                {
                   strWorkers += strFmt("%1,",setIterator.value());//     Apply range – for Worker Condition – 3 (If it doesn’t get in to this loop , strWorkers = “”) . This is what happening for condition 3 .. it is not moving in to this loop due to data and range .                                                                          value for Worker is “”

                    setIterator.next();
                }
            }
        }
        else
        {
            strWorkers = SysQuery::value(SysQueryRangeUtil::currentWorker());
        }

        rangeWorker.value(strWorkers); //     Apply range – for Worker Condition – 1 ( Current Worker)
                                                   if(filterDep)
        {
            SysQuery::clearDimensionRangesFromQuery(_query);
        }
    }
    Else   // Moves to this code if (filterCreator = NoYes::No)
    {
        rangeWorker.value(SysQuery::valueUnlimited());// Apply range – for Worker Condition – 2 ( All workers)

        if(filterDep)
        {
            SysQuery::addDimensionAttributeRange(_query,
                                                    queryDataSourceStr(PurchTableListPage, PurchaseTable),
                                                    fieldId2name(tableNum(PurchTable), fieldnum(PurchTable, DefaultDimension)),
                                                    DimensionComponent::DimensionAttribute,
                                                    filterDep,
                                                    dimAttributeDep.Name);
        }
    }

  =================================================================================================================


public static container getDepartmentRecIds(HcmWorkerRecId _workerRecId, utcdatetime _asOfDate = DateTimeUtil::utcNow())

{
    #HRMConstants

    HcmPositionWorkerAssignment positionWorkerAssignment;
    HcmPositionDetail           positionDetail;
    HcmPositionDuration         positionDuration;

    ----
    ----
while select ValidTimeState(_asOfDate) Department from positionDetail
            exists join positionWorkerAssignment
            where positionWorkerAssignment.Position == positionDetail.Position &&
                positionWorkerAssignment.Worker == _workerRecId
            exists join positionDuration
                where positionDuration.Position == positionDetail.Position
    {
        result = conIns(result, conLen(result) + 1, positionDetail.Department);
    }
}